The idea that xsl:message output should be sent to the MessageListenerSorry, read ErrorListenerwas something that was introduced to JAXP at a rather late stage (one of many regrettable occasions where the spec was changed unilaterally to match the Xalan implementation), and I decided not to implement this change as a default behaviour, because it would have been disruptive to existing applications.In Saxon, xsl:message output is directed to a Receiver, which you can nominate to the Transformer:((net.sf.saxon.Controller)transformer).setMessageEmitter(....)If you want to follow the JAXP model of sending the output to the ErrorListener, you can nominate a Receiver that does this:((net.sf.saxon.Controller)transformer).setMessageEmitter(new net.sf.saxon.event.MessageWarner())However, for your purposes, I would suggest writing your own Receiver (you can use the code of MessageWarner as a template) that writes the message directly to your logging service rather than going via the ErrorListener. That way messages won't be confused with real errors.
From: Glenn Pearson [mailto:firstname.lastname@example.org]
Sent: 22 February 2010 21:26
Subject: [saxon] cannot get ErrorListener to work
I’m trying to get messages (xsl:message output), along with any XSLT errors, to get redirected to a logger instead of going to stdout or stderr. I’ve created an ErrorListener and set it, but nothing seems to work. Here’s a code snippet that I’m using. My ErrorListener (CPAMessageListener) class is simple and straightforward, and works fine when tested alone.
CPAMessageListener listen = new CPAMessageListener();
// Create a transform factory instance.
TransformerFactory tfactory = TransformerFactory.newInstance();
// Create a transformer for the stylesheet.
Transformer transformer =
// Create the output stream
StreamResult outResult = new StreamResult(p_xmlOutput);
// Transform the source XML to System.out.
My CPAMessageListener class implements the ErrorListener methods and nothing more. It’s methods (warning, error and fatalError) never get called during the transform.
Any ideas what I’m doing wrong?
--- Glenn Pearson