Oh ok, I forgot that there was a change a
while back to get the ‘file not found’ stuff into the block that
reports via the error handler. But the error handler does report the error
codes. If the SAX2 specification doesn’t provide for that error code to
be passed on to the client app, then I guess that’s just the way it is. Its not a problem with Xerces, but
just with the error callback interface of SAX2. As I said, I’ve not
looked at that interface, so I can’t say.
If that is the case, you can still do it. Just
provide your own derivative of the SAX2 parser, and override the error callback
on the parser object, looking at the raw error callback info, then passing it back to the underlying SAX2 parser for
normal processing. I don’t know if that’s really necessary, since I’ve
not looked at the SAX2 interfaces, and perhaps you just missing something. But
that’s always a way to get to the raw parser callbacks.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 24, 2002 5:44 PM
To: [EMAIL PROTECTED]
Subject: RE: How to get the error
code during SAX parse?
I am not sure what you mean. XMLScanner traps the
exception when the target file does not exist (for example). This
means that the caller (eg DOMCount) does not get told the file does not exist -
only that 'there was an error' via the call back.
There
is no difference in the behaviour the caller sees if there error was due to
file not existing or document being malformed in terms of whether or not an
exception is thrown or the callback is called.
In
other words:
-
'fundamental errors with finding the source data' are reported via the call
back 'as parsing errors' if I understand what you are saying.
-
in DOMCount the catches around the call to parse documents will only catch
something if the code was changed to try parsing another document whilst a
parse is in progress or similar.
In
the case that the target files does not exist the caller has no way of knowing
what the actual error was without parsing the error message (which is a bit
ugly) ...
Are
you implying that the exception handling in XMLScanner::scanDocument should
actually be removed/altered to allow these 'fundamental' errors to be thrown
back to the caller?
|
|
Dean Roddey
<[EMAIL PROTECTED]>
25/09/2002 10:13 AM
Please
respond to xerces-c-dev
|
To: [EMAIL PROTECTED]
cc:
Subject: RE: How to get the
error code during SAX parse?
|
As I said, exceptions are not used to report
parsing errors, only fundamental errors with finding the source data, so the
catch after the parse is irrelevant for parsing errors. Look at the error
handler code for the DOMPrint and DOMCount examples.
-------------------------------------
Dean Roddey
The Charmed Quark
Controller
[EMAIL PROTECTED]
www.charmedquark.com
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 24, 2002 4:30 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: How to get the error code during SAX parse?
But I'm saying none of the parsers don't supply the information I'd like (ie
the actual parsing error that occurred) because the underlying scanner which is
used by both DOM and SAX parsers throws the error away ...
See XMLScanner::scanDocument - the exception handling that is invoked (if file
does not exist for example).
|
|
Dean Roddey
<[EMAIL PROTECTED]>
25/09/2002 09:23 AM
Please respond to xerces-c-dev
|
To: [EMAIL PROTECTED]
cc:
Subject: RE: How to get
the error code during SAX parse?
|
I can't speak to the SAX2 part, since I've not looked at that variant. The
parser itself does provide the information you want, but if the SAX2
specification (which the Xerces team does not define) doesn't provide a way to
pass it on, then there's not much the parser can do about it.
-------------------------------------
Dean Roddey
The Charmed Quark
Controller
[EMAIL PROTECTED]
www.charmedquark.com
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 24, 2002 4:13 PM
To: [EMAIL PROTECTED]
Subject: RE: How to get the error code during SAX parse?
Can we get some enlightenment on this (for the dummies!).
When you say the pluggable error call backs, do you mean the things you set by
calling SAX2XMLReader::setErrorHandler or SAXParser::setErrorHandler?
If so, then these are passed a SAXParseException object which does not have an
error code.
If not, which example should we look at?
>From previous discussions, even if the SAXParseException object contained
an error code it would only be one of
XMLErrs::XMLException_Fatal
XMLErrs::XMLException_Error
XMLErrs::XMLException_Warning
because XMLScanner::scanDocument basically chucks away the actual error.
So, to get the actual error code that occurred during a parse you have to hack
the Xerces code base ...
Would it make sense if the scanner passed through the actual error code to
XMLScanner::emitError and thence to its error reporter? Then each of the
error reporters for each parser can take the appropriate action (and one could
then simply subclass the relevant parser and overload the error function to
trap the actual error code).
To me there is a bit of an issue in that it is not easy to take programatic
action according to the parser failure (eg take action depending if document
was well formed but not valid versus malformed versus file does not exist).
What do people think?
Am I missing something?
|
|
Dean Roddey
<[EMAIL PROTECTED]>
25/09/2002 08:27 AM
Please respond to xerces-c-dev
|
To: [EMAIL PROTECTED]
cc:
Subject: RE: How to get the
error code during SAX parse?
|
Errors are not reported via the exceptions, they are reported via pluggable
error callbacks. An exception can only report one error, because it unwinds the
stack. The callbacks allow the parser to continue through more than one error
(if you tell it that's ok to do.) Look at the sample programs, which clearly
show how this is done.
-------------------------------------
Dean Roddey
The Charmed Quark
Controller
[EMAIL PROTECTED]
www.charmedquark.com
-----Original Message-----
From: Scot Nielsen [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 24, 2002 3:09 PM
To: 'Xerces-Dev (E-mail)'
Subject: How to get the error code during SAX parse?
Can someone
enlighten me please? There's no error code value in the SaxParseException
class...
Are all error codes
for internal use only?
Many thanks, Scot
Nielsen