You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Kevin Belhumeur <KB...@xrite.com> on 2002/11/21 16:33:20 UTC
DOM Validation of XML against a schema
> How do I validate XML against a schema when parsing using DOM as in:
>
> pDomDocument = pDOMBuilder->parse( domInputSource );
>
> I have schemas for the simple XML files in the domInputSource and am mainly interested in getting useful structure/content error messages at parse time.
>
> Thanks,
Kevin
>
> Kevin M. Belhumeur, Software Engineer
> X-Rite Incorporated
> kbelhumeur@x-rite.com
> ph: 616-257-2478
> cell: 616-644-2851
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: DOM Validation of XML against a schema
Posted by Philippe HAUTION <ha...@clr34ei.der.edf.fr>.
Hello,
You could define an ErrorHandler and then try something like this before
parsing :
parser->setErrorHandler(myErrorHandler);
parser->setValidationScheme(XercesDOMParser::Val_Always);
parser->setValidationSchemaFullChecking(true);
parser->setDoNamespaces(true);
parser->setDoSchema(true);
parser->setExitOnFirstFatalError(true); // exception si le schema
n'est pas trouve
parser->setValidationConstraintFatal(true);
parser->setIncludeIgnorableWhitespace(false);
parser->setCreateCommentNodes(false);
parser->setExternalSchemaLocation( ... );
We use XercesDomParser this way and get the parsing errors as exceptions.
Regards,
Kevin Belhumeur wrote:
>>How do I validate XML against a schema when parsing using DOM as in:
>>
>>pDomDocument = pDOMBuilder->parse( domInputSource );
>>
>>I have schemas for the simple XML files in the domInputSource and am mainly interested in getting useful structure/content error messages at parse time.
>>
>>Thanks,
>>
>Kevin
>
>>
>>Kevin M. Belhumeur, Software Engineer
>>X-Rite Incorporated
>>kbelhumeur@x-rite.com
>>ph: 616-257-2478
>>cell: 616-644-2851
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
--
Philippe Haution
EDF R&D
Département Méthodes d'Optimisation et de Simulation
1 Av du Général de Gaulle
92141 Clamart CEDEX