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();

        ErrorListener newListen;

        // Create a transform factory instance.

        TransformerFactory tfactory = TransformerFactory.newInstance();

        tfactory.setErrorListener(listen);

        // Create a transformer for the stylesheet.

        Transformer transformer =

            tfactory.newTransformer(new StreamSource(p_xsltStylesheet));

        // Create the output stream

        StreamResult outResult = new StreamResult(p_xmlOutput);

        // Transform the source XML to System.out.

        transformer.setErrorListener(listen);

        transformer.transform(new StreamSource(p_xmlSource),

                              outResult);

 

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