Hello All,
I want to validate a xml Document against a XML Schema on the local
file system. I construct the parser as follows. But I don't get a error
message on a defenetly incorrect xml file. What am I doing wrong?
Thanks and Regards
Robin
XercesDOMParser* parser = new XercesDOMParser();
parser->setValidationScheme(XercesDOMParser::Val_Always);
parser->setValidationSchemaFullChecking(true);
parser->setDoNamespaces(true);
parser->setDoSchema(true);
parser->setExternalSchemaLocation("http://www.robin.aly.de/namespaces/workinghours
working-hours.xsd");
parser->setExitOnFirstFatalError(true); // exception si le schema n'est
pas trouve
parser->setValidationConstraintFatal(true);
ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase();
parser->setErrorHandler(errHandler);
/* end if initialization */
try {
// reading and parsing the document
cout<<"reading "<<argv[1]<<endl;
parser->parse(argv[1]);
DOMDocument* document = parser->getDocument();
if (document) {
DOMElement* root = document->getDocumentElement();// This is what
we pass
to TraverserSchema
cout<<"NO ERROR"<<endl;
}
else {
cout<<"ERROR"<<endl;
}
}
// catching of the exceptions possibly throws by the DOM parser
catch (const XMLException& toCatch) {
char* message = XMLString::transcode(toCatch.getMessage());
cout << "Exception message is: \n"
<< message << "\n";
XMLString::release(&message);
return -1;
}
catch (const DOMException& toCatch) {
char* message = XMLString::transcode(toCatch.msg);
cout << "Exception message is: \n"
<< message << "\n";
XMLString::release(&message);
return -1;
}
catch (...) {
cerr<<"Other Exception"<<endl;
return 1;
}
--
Robin Aly ([EMAIL PROTECTED])
Parkring 23a
68159 Mannheim
Telefon: 0621 159 70 45
Fax: +49 621 159 60 93