Xalan-Java debugging interface.
import org.apache.xalan.xslt.XSLTProcessor;
import org.apache.xalan.xslt.trace.PrintTraceListener;
...
// Set up a PrintTraceListener object to print to a file.
java.io.FileWriter fw = new java.io.FileWriter("events.log");
java.io.PrintWriter pw = new java.io.PrintWriter(fw);
PrintTraceListener ptl = new PrintTraceListener(pw);
// 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;
// Register the PrintTraceListener with the XSLTProcessor.
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
processor.addTraceListener(ptl);
...
// Perform the transformation -- printing information to
// events.log during the process.
processor.process(new XSLTInputSource("foo.xml"),
new XSLTInputSource("foo.xsl"),
new XSLTResultTarget("foo.out"));
...
// Close the PrintWriter and FileWriter.
pw.close();
fw.close(); |