[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Re: Is there a way to catch Exceptions in xslt thrown from calling a Java function within Xalan ?


Subject: [xsl] Re: Is there a way to catch Exceptions in xslt thrown from calling a Java function within Xalan ?
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Sat, 28 Feb 2004 00:03:53 +0100

"Bill Riegel" <BRiegel@xxxxxxx> wrote in message
news:830BF4914C3C4B4EB1C438D93ABF897A0443CB@xxxxxxxxxxxxxxxxxxxxxxxxx
>
>
> Have the template below that I use with Xalan.
> Its purpose is to read a date string in one format and convert to another
> format. But if/when the input data does not match the input format an
> exception is thrown and the entire translation stops. Is there a way to
> catch the exception ?

Neither XSLT 1.0 nor XSLT 2.0 defines any exception throwing/handling
mechanism.

You can achieve this by catching the exception in your Java code and
returning a special value, which the XSLT code must then recognize and take
appropriate action.

A good technique would be to have and only call from the XSLT code one
general "despatcher" function, passing to it as parameters the name and
parameters for the actual function to be called.

Then the exception handling logic and the returning of the appropriate
special value can be implemented centrally, only in the "despatcher" thus
avoiding the need to reproduce this exception handling logic in any new
extension function that has to be written.

Of course, before even starting coding this one must clearly understand that
handling such an error condition in the XSLT code will really be meaningful
(e.g. there is a possibility of a graceful recovery and continuing the
processing) . Most often this is not the case.


Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords