We test a particular constriant in our XSLT and throw a custom exception on failure:
<xsl:when test="......">
<xsl:value-of
select="excepti on:throwExcepti on('Recording failed')"/>
</xsl:when>
Here exception is defined as:
xmlns:exception ="http://..../util.exception. ValidationExcep tionThrower"
The problem is that this kind of exception handling by-passes the java code.
In our Java client,we have the following:
{
.........
TransformerFact ory tFactory = TransformerFact ory.newInstance ();
transformer = tFactory.newTra nsformer(source );
....
StreamResult result = new StreamResult();
java.io.ByteArr ayOutputStream outputXmlResult = new
java.io.ByteArr ayOutputStream( );
result.setOutpu tStream(outputX mlResult);
transformer.tra nsform(xmlsourc e, result);
setOutXml(outpu tXmlResult.toSt ring());
return "Success";
}
catch(Validatio nException ex) {
System.out.prin tln("INSIDE VALIDATIONEXCEP TION");
......
}
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.
<xsl:when test="......">
<xsl:value-of
select="excepti on:throwExcepti on('Recording failed')"/>
</xsl:when>
Here exception is defined as:
xmlns:exception ="http://..../util.exception. ValidationExcep tionThrower"
The problem is that this kind of exception handling by-passes the java code.
In our Java client,we have the following:
{
.........
TransformerFact ory tFactory = TransformerFact ory.newInstance ();
transformer = tFactory.newTra nsformer(source );
....
StreamResult result = new StreamResult();
java.io.ByteArr ayOutputStream outputXmlResult = new
java.io.ByteArr ayOutputStream( );
result.setOutpu tStream(outputX mlResult);
transformer.tra nsform(xmlsourc e, result);
setOutXml(outpu tXmlResult.toSt ring());
return "Success";
}
catch(Validatio nException ex) {
System.out.prin tln("INSIDE VALIDATIONEXCEP TION");
......
}
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.