I don't know, I am a beginer just like you ,
The samples seem to use a lot of try catch logic like this :
Which seems to imply that an exception will be thrown,
but you need to code a try/catch to catch that "exception".
try
{
// reset document pool
parser->resetDocumentPool();
doc = sstate->parser->parseURI(xmlFile);
}
catch (const XMLException& toCatch)
{
cerr << "\nError during parsing: '" << xmlFile << "'\n"
<< "Exception message is: \n"
<< StrX(toCatch.getMessage()) << "\n" << endl;
}
catch (const DOMException& toCatch)
{
const unsigned int maxChars = 2047;
XMLCh errText maxChars + 1 ;
cerr << "\nDOM Error during parsing: '" << xmlFile << "'\n"
<< "DOMException code is: " << toCatch.code << endl;
if (DOMImplementation::loadDOMExceptionMsg(
toCatch.code, errText, maxChars))
cerr << "Message is: " << StrX(errText) << endl;
}
catch (...)
{
// cerr << "\nUnexpected exception during parsing: '" <<
// xmlFile << "'\n";
hcsRet->code = 18;
hcsRet->reas = 4;
throw 18;
}
if (errorHandler.getSawErrors())
{
// cerr << "\nErrors occurred, no output available\n" << endl;
hcsRet->code = 18;
hcsRet->reas = 5;
throw 18;
}
The interesting thing in the sample code that I cut and pasted into my
app
is that the error-handler sets an error-flag which is then tested in :
errorHandler.getSawErrors()
But, you ask some very good questions (which I agree deserve an answer )
-----Original Message-----
From: Nick Bastin [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 4:44 PM
To: [EMAIL PROTECTED]
Subject: Re: Parser not failing on bad schema?
On Apr 6, 2004, at 6:08 PM, Bovy, Stephen J wrote:
> You forgot to set the error handler, at least , its not in the code
> snippet you posted.
Ok, well, I did set the error handler, I just didn't include the code
for that. That was supposed to be inferred from my comment that the
error handler reports no errors, but I probably should have been more
explicit. Is the error handler the only way to get an indication that
the validation failed? My thought was that a NULL DOMDocument should be
returned, or an exception should be thrown... (Or there'd be some API
on DOMDocument to ask if it was valid)
--
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]