Scott wrote:
> > Well, the problem is, I think, that the creation of the new exception in
> > fatalError will create a new stack trace, which I don't think is what you
> > want.
I replied:
> You're right; I should modify the incoming exception.
Actually I don't see how I can do that. A TransformerException is pretty
much immutable, so I guess I must throw the one that was passed in without
altering it.
Just looking at the API for ErrorListener again, it seems to me that it is
the responsibility of the Transformer or TransformerFactory to treat any
TransformerException that is thrown by its ErrorListener as the one and
only definitive signal to stop processing.
Anyway, I suppose that it is wrong of the calling application to assume in
the event of an error during the invocation of
TransformerFactory#newTemplates that the
Transformer[Configuration]Exception thrown will contain a message that has
been formatted by the ErrorListener.
The correct approach seems to be for the ErrorListener to take care of
immediately reporting or just collecting error info on behalf of the
application, and to only use its throwable exceptions as a means of
signalling to the transformer/factory to stop processing.
The application should therefore use the exception it gets from the
transformer/factory as just an indicator of trouble. There is no reason to
believe that this exception will contain a meaningful message, even though
it is likely to wrap the process-halting exception that came back from the
ErrorListener. The application *should* get its info about what the errors
actually were from somewhere else (if it even cares).
So my previous implication that the ErrorListener is strictly supplemental
is not entirely accurate. Clear as mud. :)
At any rate... Xalan should probably not interpret a halt-processing-now
exception coming back from an ErrorListener as a reason to call
ErrorListener#fatalError. How to go about that, I'm not sure, since at
that point you're usually in SAX land and are restricted in what kind of
exceptions you can throw.
- Mike
____________________________________________________________________________
mike j. brown, fourthought.com | xml/xslt: http://skew.org/xml/
denver/boulder, colorado, usa | personal: http://hyperreal.org/~mike/