Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

XSLT exception handling  RSS feed

Ranadhir Nag
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We test a particular constriant in our XSLT and throw a custom exception on failure:

<xsl:when test="......">
select="exception:throwException('Recording failed')"/>

Here exception is defined as:
The problem is that this kind of exception handling by-passes the java code.
In our Java client,we have the following:


TransformerFactory tFactory = TransformerFactory.newInstance();

transformer = tFactory.newTransformer(source);
StreamResult result = new StreamResult(); outputXmlResult = new;
transformer.transform(xmlsource, result);

return "Success";


catch(ValidationException ex) {
finally {
return "failure";


The exception thrown by XSLT does not get trapped by the error handler in the client.
How can XSLT be adapted to throw a 'catchable' exception.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!