xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Williams, Rodger" <Rodger.Willi...@zaf.xerox.com>
Subject Xerces Parser Validation
Date Mon, 03 Feb 2003 17:49:10 GMT
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

For example if file content like "12345", exception not caught.

Here is my code:

DOMImplementation* impl =  NULL;
DOMBuilder*        parser = NULL;
DOMDocument*       doc = NULL;

impl =
parser =
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) {
	return false;
catch (DOMException* pE) {
	return false;
catch (...) {
	printf("Unknown error\n");
	return false;

To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

View raw message