Hi,
I'm having trouble getting schema validation to work properly with 1.6.0;
depending on whether I use a validating SAX- or DOMParser, I get different
(erroneous) outcomes. It should be noted that I've just recently started
using the Xerces C++, but have failed to find any help on the following.
(My apologies if issues like this are dealt with in an FAQ I've overlooked.)
Here's the thing ('parser' being the DOMParser ref., saxParser
the....SAXParser!):
-----------------------------------
try
{
parser->setDoSchema(true);
parser->setValidationScheme(DOMParser::Val_Auto);
parser->setExternalSchemaLocation("file:///C:/projekt/GPS/GDL/xerces/gdlsche
ma.xsd");
parser->setValidationSchemaFullChecking(true); //These properties
being
set, you'd think it would work!
parser->setValidationConstraintFatal(true);
parser->setExitOnFirstFatalError(true);
parser->setIncludeIgnorableWhitespace(false);
parser->setErrorHandler(new GDLErrorHandler); //The handler just
throws the exception right back at caller..
parser->reset();
saxParser->setDoSchema(true);
saxParser->setValidationScheme(SAXParser::Val_Always);
saxParser->setExternalSchemaLocation("file:///C:/projekt/GPS/GDL/xerces/gdls
chema.xsd");
saxParser->setValidationSchemaFullChecking(true);
saxParser->setValidationConstraintFatal(true);
saxParser->setExitOnFirstFatalError(true);
saxParser->setErrorHandler(new GDLErrorHandler);
try {
//saxParser->parse("file:///C:/projekt/GPS/GDL/xerces/example2.xml");
//Alternating between parsers. Always to no avail.
parser->parse("file:///C:/projekt/GPS/GDL/xerces/example2.xml");
} catch (SAXParseException &e) {...}
-----------------------------------
Using the DOMParser no errors are found no matter how faulty the XML source.
Using the SAXParser I get a SAXParseException alright, but this regardless
of how _correct_ the XML source is. The schema file is correct (tested in
XMLSpy and other tools).
Using the CLI sample app 'SAX2Count', things work fine (validates/fails as
it should), using 'DOMCount' I get an 'Unexpected exception' at line 2, char
12, no matter if the XML is valid or not....
Could there be encoding problems? Or do I just suck? ('fraid the latter is
more likely...)
Bests,
Christer Lindqvist
Stockholm
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]