This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Xalan, errors and ErrorListener
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] Xalan, errors and ErrorListener
- From: Myriam_Midy at lotus dot com
- Date: Thu, 9 Aug 2001 16:32:55 -0400
- Cc: xalan-dev at xml dot apache dot org
- Reply-To: xsl-list at lists dot mulberrytech dot com
I am forwarding this question to the xalan list where it really belongs and
one of us will take a look at it. Hopefully you are subscribed to the xalan
list (xalan-dev@xml.apache.org).
Myriam
Mike Brown <mike@skew.org>
Sent by: To: xsl-list@lists.mulberrytech.com
owner-xsl-list@lists.mulber cc: sboag@apache.org, (bcc: Myriam
rytech.com Midy/CAM/Lotus)
Subject: [xsl] Xalan, errors and
ErrorListener
08/09/01 04:12 PM
Please respond to xsl-list
I'm using Xalan 2.2.D6, trying to use my own ErrorListener to nicely format
problems
encountered during stylesheet preparation. I register an instance of the
ErrorListener
implementation with the TransformerFactory, and then I call the factory's
newTemplates
method to get the prepared stylesheet.
My stylesheet intentionally contains a bad attribute name in an
<xsl:template> start tag,
causing the ErrorListener's error method to be invoked.
Both my error and fatalError methods prepare a formatted String using info
in the
TransformerException that is passed into them, and then they throw a new
TransformerException that contains only this String as its message.
Apparently this isn't a very good way to go about it because Xalan's
StylesheetHandler
class catches this new TransformerException, wraps it in a SAXException,
which gets
thrown and makes its way up to the TransformerFactoryImpl which blindly
takes it as a
random parsing error. It then gets wrapped in a new TransformerException,
which is passed
to the ErrorListener's fatalError method.
I tried to look at TransformerFactoryImpl and StylesheetHandler but
couldn't figure out
how it avoids an infinite loop of passing the exception back and forth
between the
factory's newTemplates method and my fatalError method. Yet somehow we get
out of it and
in the end I get a TransformerException with a message saying something
along the lines
of "There was a fatal error. Here it is: There was an error. Here it is:
(...)".
If Xalan's behavior is reasonable, I don't see how I can easily write my
ErrorListener
implementation to distinguish between an error and a fatal error. The fatal
error might
actually be a regular error that has already been reported. Is this really
the way it
should work?
- Mike
____________________________________________________________________________
mike j. brown, fourthought.com | xml/xslt: http://skew.org/xml/
denver/boulder, colorado, usa | personal: http://hyperreal.org/~mike/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list