private static void instrumentTransformer(Transformer transformer) throws Exception {
        transformer.setErrorListener(new TransformerErrorListener());

        if (transformer instanceof TransformerHandler) {
            transformer = ((TransformerHandler) transformer).getTransformer();
        }
        if (transformer instanceof TransformerImpl) {
            final TraceManager tm = ((TransformerImpl) transformer).getTraceManager();
            final PrintTraceListener ptl = new PrintTraceListener(new PrintWriter(System.out));
            // Print information as each node is 'executed' in the stylesheet.
            ptl.m_traceElements = true;
            // Print information after each result-tree generation event.
            ptl.m_traceGeneration = true;
            // Print information after each selection event.
            ptl.m_traceSelection = true;
            // Print information whenever a template is invoked.
            ptl.m_traceTemplates = true;
            // Print information whenever an extension call is made.
            ptl.m_traceExtension = true;
            tm.addTraceListener(ptl);
        }
    }
private static void instrumentTransformer ( Transformer transformer ) throws Exception { transformer . setErrorListener ( new TransformerErrorListener ( ) ) ; if ( transformer instanceof TransformerHandler ) { transformer = ( ( TransformerHandler ) transformer ) . getTransformer ( ) ; } if ( transformer instanceof TransformerImpl ) { final TraceManager tm = ( ( TransformerImpl ) transformer ) . getTraceManager ( ) ; final PrintTraceListener ptl = new PrintTraceListener ( new PrintWriter ( System . out ) ) ; ptl . m_traceElements = true ; ptl . m_traceGeneration = true ; ptl . m_traceSelection = true ; ptl . m_traceTemplates = true ; ptl . m_traceExtension = true ; tm . addTraceListener ( ptl ) ; } }
Adds a little verbosity to a constructed <code>Transformer</code>.

@param transformer
The <code>Transformer</code> which may produce some output.
@throws Exception
If setting/adding a listener gives a problem.