Which features should be set to which values to ensure that the xml document
being parsed(as dom document) is a valid xml document according to xml
standards. I don't set an error handler. Is it neccesary to set an error
handler in order to trap
invalid xml documents?
I parse a file to construct the dom document. If I parse a valid xml file,
the dom doc is constructed and I can work with it. BUT if I parse an invalid
file, no exceptions are caught. How am I going to trap invalid xml
documents?
For example if file content like "12345", exception not caught.
Here is my code:
DOMImplementation* impl = NULL;
DOMBuilder* parser = NULL;
DOMDocument* doc = NULL;
impl =
DOMImplementationRegistry::getDOMImplementation(XMLString::transcode("Core")
);
parser =
((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYN
CHRONOUS, 0);
parser->setFeature(XMLUni::fgDOMNamespaces, true);
parser->setFeature(XMLUni::fgXercesSchema, true);
parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
parser->setFeature(XMLUni::fgDOMValidateIfSchema, true);
parser->setFeature(XMLUni::fgDOMValidation, true);
parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
try {
doc = parser->parseURI(pszFile);
printf("Document has been parsed\n");
}
catch (XMLException* pE) {
printf("%s\n",XMLString::transcode(pE->getMessage()));
return false;
}
catch (DOMException* pE) {
printf("%s\n",XMLString::transcode(pE->msg));
return false;
}
catch (...) {
printf("Unknown error\n");
return false;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]