Hello,
I've studied a strange behaviour when using an error listener:
Let's have a look at the following example:
------------8X------------8X------------8X------------8X------------
1 try {
2 TransformerFactory tFactory = TransformerFactory.newInstance();
3 Transformer transformer = tFactory.newTransformer (sourceQuery);
4 transformer.setErrorListener(myListener);
5 transformer.transform( sourceInput, io_Result);
6 } catch ( TransformerException ex) {
7 throw new MyException("Fatal error: "
8 + ex.getMessageAndLocation() );
9 }
------------8X------------8X------------8X------------8X------------
"MyException" is catched and send to the listener, too.
When setting the listner (line 4), this is the output when an error
occurs:
------------8X--[Error Listener]--8X------------8X------------8X---
MY_ERROR_MESSAGE; SystemID: file:///myXSLT.xslt; Line#: 525; Column#: 70
(MY_ERROR_MESSAGE)
Fatal error: [java.lang.NullPointerException]
------------8X--[Error Listener]--8X------------8X------------8X---
When NOT setting the listner, that is comment out line 4, this is the
output when an error occurs:
------------8X------------8X------------8X------------8X------------
Fatal error: MY_ERROR_MESSAGE [javax.xml.transform.TransformerException:
MY_ERROR_MESSAGE]
------------8X------------8X------------8X------------8X------------
Conclusion: When setting an error listener, the thrown
TransformerException's message is removed and its exception is set to
an NullPointerException. In my case, the nested exception was a
DOMException which is never found in the transformer exception...
I think this is a bug in Xalan, isn't it?
Best regards,
Jens