xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gareth Reakes <gar...@decisionsoft.com>
Subject Re: Xerces Parser Validation
Date Tue, 04 Feb 2003 11:38:22 GMT
Hi,
	you do need to set an errorhandler if you want to know about 
errors. There is an example one in the samples.

Gareth


On Mon, 3 Feb 2003, Williams, Rodger wrote:

> 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: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 

-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




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


Mime
View raw message