C
christian.eickhoff
Hi Everyone,
I am currently implementing an XercesDOMParser to parse an XML file and
to validate this file against its XSD Schema file which are both
located on my local HD drive. For this purpose I set the corresponding
XercesDOMParser feature as shown in the upcoming subsection of my code.
As far as I understand, the parsing process should throw an
DOMException in case the XML file doesn't match the Schema file (e.g.
Element declarations mismatch..) but in my case nothing happens at all.
I even set parser->setValidationConstraintFatal(true) but this also
doesnt help. Have i missed to implement some certain Exception Handler?
Does anybody has an idea what I am doing wrong?
XercesDOMParser* XMLparser = new XercesDOMParser();
// optionally set some features
XMLparser->setDoNamespaces(true);
XMLparser->setDoSchema(true);
XMLparser->setDoValidation(true);
XMLparser->setValidationScheme(XercesDOMParser::Val_Always);
XMLparser->setExternalNoNamespaceSchemaLocation(myXSDfilepath);
XMLparser->setValidationSchemaFullChecking(true);
XMLparser->setValidationConstraintFatal(true);
//Define Error Handler
ErrorHandler *errHandler = (ErrorHandler*) new HandlerBase();
XMLparser->setErrorHandler(errHandler);
//parsing the according XML file
try
{
XMLparser->parse(myXMLfilepath);
}
//Exception Handling if parsing fails
catch (const XMLException& toCatch)
{
char* message = XMLString::transcode(toCatch.getMessage());
cout << "Exception during parsing. " << "Exception message is: \n"
<< message << "\n";
XMLString::release(&message);
return -1;
}
catch (const DOMException& toCatch)
{
char* message = XMLString::transcode(toCatch.msg);
cout << "Exception during parsing. " << "Exception message is: \n"
<< message << "\n";
XMLString::release(&message);
return -1;
}
catch (...)
{
cout << "Unexpected Exception \n";
return -1;
}
PLEASE! Its urgent.. Can anyone give me at least a hint?
Thanks in advance for response..
I am currently implementing an XercesDOMParser to parse an XML file and
to validate this file against its XSD Schema file which are both
located on my local HD drive. For this purpose I set the corresponding
XercesDOMParser feature as shown in the upcoming subsection of my code.
As far as I understand, the parsing process should throw an
DOMException in case the XML file doesn't match the Schema file (e.g.
Element declarations mismatch..) but in my case nothing happens at all.
I even set parser->setValidationConstraintFatal(true) but this also
doesnt help. Have i missed to implement some certain Exception Handler?
Does anybody has an idea what I am doing wrong?
XercesDOMParser* XMLparser = new XercesDOMParser();
// optionally set some features
XMLparser->setDoNamespaces(true);
XMLparser->setDoSchema(true);
XMLparser->setDoValidation(true);
XMLparser->setValidationScheme(XercesDOMParser::Val_Always);
XMLparser->setExternalNoNamespaceSchemaLocation(myXSDfilepath);
XMLparser->setValidationSchemaFullChecking(true);
XMLparser->setValidationConstraintFatal(true);
//Define Error Handler
ErrorHandler *errHandler = (ErrorHandler*) new HandlerBase();
XMLparser->setErrorHandler(errHandler);
//parsing the according XML file
try
{
XMLparser->parse(myXMLfilepath);
}
//Exception Handling if parsing fails
catch (const XMLException& toCatch)
{
char* message = XMLString::transcode(toCatch.getMessage());
cout << "Exception during parsing. " << "Exception message is: \n"
<< message << "\n";
XMLString::release(&message);
return -1;
}
catch (const DOMException& toCatch)
{
char* message = XMLString::transcode(toCatch.msg);
cout << "Exception during parsing. " << "Exception message is: \n"
<< message << "\n";
XMLString::release(&message);
return -1;
}
catch (...)
{
cout << "Unexpected Exception \n";
return -1;
}
PLEASE! Its urgent.. Can anyone give me at least a hint?
Thanks in advance for response..