本文整理汇总了C++中DOMParser::setValidationScheme方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMParser::setValidationScheme方法的具体用法?C++ DOMParser::setValidationScheme怎么用?C++ DOMParser::setValidationScheme使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMParser
的用法示例。
在下文中一共展示了DOMParser::setValidationScheme方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
bool verbose = false;
#if 0
DOMParser::ValSchemes gValScheme = DOMParser::Val_Auto;
bool gDoNamespaces = true;
bool gDoSchema = true;
bool gSchemaFullChecking = false;
bool gDoCreate = false;
#endif
MFileOperations f;
char path[1024];
f.expandPath(path, "MESA_TARGET", "runtime");
::strcat(path, "/IHE-syslog-audit-message-4.xsd");
char* schemaDef = path;
int detailLevel = 1;
MString tmp;
while (--argc > 0 && (*++argv)[0] == '-') {
switch (*(argv[0] + 1)) {
case 'l':
argc--; argv++;
if (argc < 1)
usage();
tmp = *argv;
detailLevel = tmp.intData();
break;
case 's':
argc--; argv++;
if (argc < 1)
usage();
schemaDef = *argv;
break;
case 'v':
verbose = true;
break;
default:
break;
}
}
if (argc < 1)
usage();
// Initialize the XML4C2 system
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& e) {
cout << "Unable to initialize Xerces-c software"
<< DOMString(e.getMessage()) << endl;
return 1;
}
DOMParser *parser = new DOMParser;
parser->setValidationScheme(DOMParser::Val_Auto);
parser->setDoNamespaces(true);
parser->setDoSchema(true);
parser->setValidationSchemaFullChecking(true);
if (schemaDef != "") {
parser->setExternalNoNamespaceSchemaLocation(schemaDef);
}
DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter();
parser->setErrorHandler(errReporter);
parser->setCreateEntityReferenceNodes(false);
parser->setToCreateXMLDeclTypeNode(true);
bool errorFlag = false;
try {
parser->parse(*argv);
int count = parser->getErrorCount();
if (count > 0) {
errorFlag = true;
return 1;
}
}
catch (const XMLException& e) {
cout << "Parsing error: " << DOMString(e.getMessage()) << endl;
return 1;
}
catch (const DOM_DOMException& e) {
cout << "DOM Error: " << e.code << endl;
return 1;
}
catch (...) {
cout << "Unspecified error" << endl;
return 1;
}
DOM_Document doc = parser->getDocument();
unsigned int elementCount = doc.getElementsByTagName("*").getLength();
//.........这里部分代码省略.........
示例2: main
//.........这里部分代码省略.........
sax2parser->setErrorHandler(&saxErrorHandler);
// Instantiate the deprecated DOM parser with its memory manager.
MemoryMonitor *depDOMMemMonitor = new MemoryMonitor();
DOMParser *depDOMParser = new (depDOMMemMonitor)DOMParser(0, depDOMMemMonitor);
depDOMParser->setErrorHandler(&saxErrorHandler);
// Instantiate the SAX 1 parser with its memory manager.
MemoryMonitor *sax1MemMonitor = new MemoryMonitor();
SAXParser *saxParser = new (sax1MemMonitor) SAXParser(0, sax1MemMonitor);
saxParser->setErrorHandler(&saxErrorHandler);
// set features
domBuilder->setFeature(XMLUni::fgDOMNamespaces, doNamespaces);
sax2parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, doNamespaces);
depDOMParser->setDoNamespaces(doNamespaces);
saxParser->setDoNamespaces(doNamespaces);
domBuilder->setFeature(XMLUni::fgXercesSchema, doSchema);
sax2parser->setFeature(XMLUni::fgXercesSchema, doSchema);
depDOMParser->setDoSchema(doSchema);
saxParser->setDoSchema(doSchema);
domBuilder->setFeature(XMLUni::fgXercesSchemaFullChecking, schemaFullChecking);
sax2parser->setFeature(XMLUni::fgXercesSchemaFullChecking, schemaFullChecking);
depDOMParser->setValidationSchemaFullChecking(schemaFullChecking);
saxParser->setValidationSchemaFullChecking(schemaFullChecking);
if (domBuilderValScheme == AbstractDOMParser::Val_Auto)
{
domBuilder->setFeature(XMLUni::fgDOMValidateIfSchema, true);
sax2parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
sax2parser->setFeature(XMLUni::fgXercesDynamic, true);
depDOMParser->setValidationScheme(DOMParser::Val_Auto);
saxParser->setValidationScheme(SAXParser::Val_Auto);
}
else if (domBuilderValScheme == AbstractDOMParser::Val_Never)
{
domBuilder->setFeature(XMLUni::fgDOMValidation, false);
sax2parser->setFeature(XMLUni::fgSAX2CoreValidation, false);
depDOMParser->setValidationScheme(DOMParser::Val_Never);
saxParser->setValidationScheme(SAXParser::Val_Never);
}
else if (domBuilderValScheme == AbstractDOMParser::Val_Always)
{
domBuilder->setFeature(XMLUni::fgDOMValidation, true);
sax2parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
sax2parser->setFeature(XMLUni::fgXercesDynamic, false);
depDOMParser->setValidationScheme(DOMParser::Val_Always);
saxParser->setValidationScheme(SAXParser::Val_Always);
}
// enable datatype normalization - default is off
domBuilder->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
XERCES_STD_QUALIFIER ifstream fin;
bool more = true;
// the input is a list file
if (doList)
fin.open(argV[argInd]);
if (fin.fail()) {
XERCES_STD_QUALIFIER cerr <<"Cannot open the list file: " << argV[argInd] << XERCES_STD_QUALIFIER endl;
return 2;
}