Hey Stephen,
Stephen Collyer wrote:
Jason
I posted this to the Xerces-p mailing list a few days
ago, but go no response. As I'm pushed for time, is there
any chance you could let me know if the approach to the
problem outlined by Alberto Massari is possible with the
Perl bindings - if not, I'll waste no more time on it.
Sorry - I'm on a sub-optimal email link at the moment...
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.
Not quite - Alberto suggests creating a new subclass of SAXParser and
over-riding the error() method on the parser - very messy from Perl land
at the moment because SWIG doesn't (easily) allow you to make a Perl
subclass of a C++ from Perl - with Python or Ruby I think you could, but
the needed functionality is called directors and it hasn't been built
into SWIG-Perl yet - that is on my todo list, but, well, I haven't done
it yet. If I could get another SWIG related contract maybe I could swing
it, but until then it's too big a job.
So the short answer is - I'm afraid this is just not really possible at
the moment.
Wish I had better news. Cheers, jas.
-------- 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
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]