Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

Impala::Application::SDash::Sax2Reader::Sax2Reader ( int  argC,
const char *  argV[],
Sax2Handler handler 
) [inline]

Definition at line 48 of file Sax2Reader.h.

References mDoList, mDoNamespaces, mDoSchema, mFileToRead, mHandler, mIdentityConstraintChecking, mLocaleStr, mNamespacePrefixes, mParser, mProperlyConstructed, mRecognizeNEL, mSchemaFullChecking, and mValScheme.

00048                                                                    : mParser(0)
00049     {
00050         mProperlyConstructed = true;
00051 
00052         mValScheme = SAX2XMLReader::Val_Auto;
00053         mDoNamespaces = true;
00054         mDoSchema = true;
00055         mSchemaFullChecking = false;
00056         mIdentityConstraintChecking = true;
00057         mDoList = false;
00058         mNamespacePrefixes = false;
00059         mRecognizeNEL = false;
00060 
00061         memset(mLocaleStr, 0, sizeof mLocaleStr);
00062 
00063         // check the flags
00064         int argInd;
00065         for (argInd = 0; argInd < argC; argInd++)
00066         {
00067             // Break out on first parm not starting with a dash
00068             if (argV[argInd][0] != '-')
00069                 break;
00070 
00071             if (!strncmp(argV[argInd], "-v=", 3)
00072                   ||  !strncmp(argV[argInd], "-V=", 3))
00073             {
00074                 const char* const parm = &argV[argInd][3];
00075 
00076                 if (!strcmp(parm, "never"))
00077                     mValScheme = SAX2XMLReader::Val_Never;
00078                 else if (!strcmp(parm, "auto"))
00079                     mValScheme = SAX2XMLReader::Val_Auto;
00080                 else if (!strcmp(parm, "always"))
00081                     mValScheme = SAX2XMLReader::Val_Always;
00082                 else
00083                 {
00084                     XERCES_STD_QUALIFIER cerr << "Unknown -v= value: " << parm << XERCES_STD_QUALIFIER endl;
00085                     mProperlyConstructed = false;
00086                     return;
00087                 }
00088             }
00089              else if (!strcmp(argV[argInd], "-n")
00090                   ||  !strcmp(argV[argInd], "-N"))
00091             {
00092                 mDoNamespaces = false;
00093             }
00094              else if (!strcmp(argV[argInd], "-s")
00095                   ||  !strcmp(argV[argInd], "-S"))
00096             {
00097                 mDoSchema = false;
00098             }
00099              else if (!strcmp(argV[argInd], "-f")
00100                   ||  !strcmp(argV[argInd], "-F"))
00101             {
00102                 mSchemaFullChecking = true;
00103             }
00104              else if (!strcmp(argV[argInd], "-i")
00105                   ||  !strcmp(argV[argInd], "-I"))
00106             {
00107                 mIdentityConstraintChecking = false;
00108             }
00109              else if (!strcmp(argV[argInd], "-l")
00110                   ||  !strcmp(argV[argInd], "-L"))
00111             {
00112                 mDoList = true;
00113             }
00114              else if (!strcmp(argV[argInd], "-p")
00115                   ||  !strcmp(argV[argInd], "-P"))
00116             {
00117                 mNamespacePrefixes = true;
00118             }
00119              else if (!strcmp(argV[argInd], "-special:nel"))
00120             {
00121                 // turning this on will lead to non-standard compliance behaviour
00122                 // it will recognize the unicode character 0x85 as new line character
00123                 // instead of regular character as specified in XML 1.0
00124                 // do not turn this on unless really necessary
00125                  mRecognizeNEL = true;
00126             }
00127              else if (!strncmp(argV[argInd], "-locale=", 8))
00128             {
00129                  // Get out the end of line
00130                  strncpy(mLocaleStr, &(argV[argInd][8]), sizeof mLocaleStr);
00131             }                   
00132             else
00133             {
00134                 XERCES_STD_QUALIFIER cerr << "Unknown option '" << argV[argInd]
00135                     << "', ignoring it\n" << XERCES_STD_QUALIFIER endl;
00136             }
00137         }
00138 
00139         //
00140         //  There should be one and only one parameter left, and that
00141         //  should be the file name.
00142         //
00143         if (argInd != argC - 1)
00144         {
00145             XERCES_STD_QUALIFIER cerr << "Invalid parameter count to Sax2Reader::Sax2Reader(..)"
00146                 << XERCES_STD_QUALIFIER endl;
00147             mProperlyConstructed = false;
00148             return;
00149         }
00150         mFileToRead = std::string(argV[argInd]);
00151 
00152         // Initialize the XML4C2 system
00153         try
00154         {
00155             if (strlen(mLocaleStr))
00156             {
00157                 XMLPlatformUtils::Initialize(mLocaleStr);
00158             }
00159             else
00160             {
00161                 XMLPlatformUtils::Initialize();
00162             }
00163 
00164             if (mRecognizeNEL)
00165             {
00166                 XMLPlatformUtils::recognizeNEL(mRecognizeNEL);
00167             }
00168         }
00169 
00170         catch (const XMLException& toCatch)
00171         {
00172             XERCES_STD_QUALIFIER cerr << "Error during initialization! Message:\n"
00173                 << StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl;
00174             mProperlyConstructed = false;
00175             return;
00176         }
00177 
00178         //
00179         //  According to what we were told on
00180         //  the command line, set the parser to validate or not.
00181         //
00182         mParser = XMLReaderFactory::createXMLReader();
00183         mParser->setFeature(XMLUni::fgSAX2CoreNameSpaces, mDoNamespaces);
00184         mParser->setFeature(XMLUni::fgXercesSchema, mDoSchema);
00185         mParser->setFeature(XMLUni::fgXercesSchemaFullChecking, mSchemaFullChecking);
00186         mParser->setFeature(XMLUni::fgXercesIdentityConstraintChecking, mIdentityConstraintChecking);
00187         mParser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, mNamespacePrefixes);
00188 
00189         if (mValScheme == SAX2XMLReader::Val_Auto)
00190         {
00191             mParser->setFeature(XMLUni::fgSAX2CoreValidation, true);
00192             mParser->setFeature(XMLUni::fgXercesDynamic, true);
00193         }
00194         if (mValScheme == SAX2XMLReader::Val_Never)
00195         {
00196             mParser->setFeature(XMLUni::fgSAX2CoreValidation, false);
00197         }
00198         if (mValScheme == SAX2XMLReader::Val_Always)
00199         {
00200             mParser->setFeature(XMLUni::fgSAX2CoreValidation, true);
00201             mParser->setFeature(XMLUni::fgXercesDynamic, false);
00202         }
00203 
00204         mParser->setContentHandler(handler);
00205         mParser->setErrorHandler(handler);
00206         mHandler = handler;
00207 
00208     } //ctor


Generated on Fri Mar 19 10:49:39 2010 for ImpalaSrc by  doxygen 1.5.1