Leif Goodwin wrote:
We've tried the above code and it does not validate the XML file. All it does
is check that it is well formed. Here is the hacked code:
/* initialize xerces system before usig API: DOM, SAX, SAX2 */
try {
xercesc::XMLPlatformUtils::Initialize();
}
catch (const XMLException &e) {
char *message = XMLString::transcode(e.getMessage());
//qDebug() << "Error during XML initialization: " << message <<
endl;
XMLString::release(&message);
//return;
}
/* actual xerces work */
char *xml_file = "D:\\Development\\Chronicle\\Example Schemas and Form
Templates\\DrillData_1.xml";
char *xml_schema = "D:\\Development\\Chronicle\\Example Schemas and Form
Templates\\newDrillData.xsd";
These are not valid URLs, because URLS cannot contain the space
character, nor the '\' character. Instead, put these files in a
directory with no space, and reference to them with legal URLs:
file:///Development/Chronicle/Example/newDrillData.xsd
SAXParser *parser = new SAXParser();
I would recommend you use a SAX2XMLReader, rather than a SAXParser.
CSaxParserErrorHandler errorHandler;
parser->setErrorHandler(&errorHandler);
//parser->setDoValidation(true);
You have this commented out, so why would expect validation to occur?
parser->setDoNamespaces(true);
You also need to call parser->setDoSchema(true).
try
{
parser->setExternalSchemaLocation(xml_schema);
As Alberto pointed out, this function does not accept a URL, it accepts
a URI/URL pair. The first is the namespace URI for the schema. The
second is the URL for the schema document itself. See here for more
information:
http://www.w3.org/TR/xmlschema-0/#ref40
If the schema does not use a namespace, then call
setExternalNoNamespaceSchemaLocation() with just the URL for the schema
document.
I would suggest you try running the SAX2Print sample application in the
debugger and see what that code does.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]