[Fwd: Re: Well-formed v. invalid errors]
Stephen Collyer <[email protected]> Mon, 19 Mar 2007 14:51:26 +0000
| Newsgroups | gmane.text.xml.xerces-p.devel |
|---|---|
| Message-ID | <[email protected]> |
I'm forwarding the question below that I posted to the C++ list, as I'm looking for a Perl solution, though Alberto has given me a C++ solution. I'm trying to figure out if this can be done in Perl land. AFAICS, I'd need to override PerlErrorHandler::fatal_error and get access to the errDomain value. However, there doesn't seem to be a getter for this provided in XML::Xerces so I'm beginning to think I'm out of luck, or perhaps unaware of some other way to do this. Any suggestions ? -------- Original Message -------- Subject: Re: Well-formed v. invalid errors Date: Mon, 12 Mar 2007 22:50:50 +0100 From: Alberto Massari <[email protected]> Reply-To: [email protected] To: [email protected] References: <[email protected]> At 20.14 12/03/2007 +0000, Stephen Collyer wrote: >This may be a trivial question but I can't see an obvious answer >so feel free to flame if I'm being idiotic .. > >Is there a straightforward way of distinguishing a non-well-formed >XML error from an invalid XML error, when running Xerces in validating >mode ? Hi Steve, that isn't a trivial question.... The only way I can see is that you create a new parser class by deriving either XercesDOMParser or SAXParser, and override the error( const unsigned int code , const XMLCh* const errDomain , const XMLErrorReporter::ErrTypes errType , const XMLCh* const errorText , const XMLCh* const systemId , const XMLCh* const , const XMLSSize_t lineNum , const XMLSSize_t colNum) method. At that point, if errDomain is XMLUni::fgValidityDomain ("http://apache.org/xml/messages/XMLValidity"), it's a validation error; if it's XMLUni::fgXMLErrDomain ("http://apache.org/xml/messages/XMLErrors") it's a well-formedness error. Be sure to call the base class method, in order to preserve the original functionality of the parser. Hope this helps, Alberto -- Regards Steve Collyer Netspinner Ltd