Hi,
I'm just starting to use xerces so hopefully I'm just missing something obvious.
I have a schema file MySchema.xsd and a xml file example.xml and want
to validate and parse the XML file. I used xmllint (on Linux) to
verify that my schema is correct and that example.xml is valid
according the schema.
Here's the C++ code I wrote to perform this task with Xerces:
=============================================
XMLPlatformUtils::Initialize();
...
DOMImplementation *impl = DOMImplementation::getImplementation();
DOMBuilder *parser = ((DOMImplementationLS *)impl)->
createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
//parser->setFeature(XMLUni::fgXercesSchema, true);
//parser->setFeature(XMLUni::fgDOMNamespaces, true);
//parser->setFeature(XMLUni::fgDOMValidateIfSchema, true);
parser->setFeature(XMLUni::fgDOMValidation, true);
parser->loadGrammar("MySchema.xsd", Grammar::SchemaGrammarType, true);
DOMDocument *doc = parser -> parseURI("example.xml");
=============================================
When I run this version (with the first 3 setFeature()'s commented
out) the parseURI function generates an "Unknown element" error for
every tag in example.xml. If I uncomment any of the 3 setFeatures the
the file is parsed correctly but does not validate according to the
schema.
I verified that the loadGrammar() reads and processes the schema
correctly by adding errors to my schema files and they would be
reported.
Does anyone has any idea for what I need to do?
Thanks,
Alain