Debugging XSLT called from Java

To debug Java™ that calls an XSL transformation, you use the Java and mixed language debug launch configuration or launch shortcut.

About this task

For information about Java and mixed language debug, see the Java and mixed language debugging section of the help.

You use different Java APIs to invoke an XSL transformation from Java depending on whether you are using the XSLT 1.0 or 2.0 processor. The Java API for XSLT 1.0 is JAXP and the Java API for XSLT 2.0 is XCI.

When you debug Java that calls an XSL transformation, you can debug from the Java code into the XSL transformation by completing the following steps:

Procedure

  1. Set a breakpoint on the line in the Java that calls the XSL transformation (this is the line that invokes the transform() method on the Transformer object for XSLT 1.0 or the line that invokes the execute() method on the XSLTExecutable object for XSLT 2.0). Alternatively, step to this line.
  2. Set a breakpoint in the stylesheet or the XML input document and then run to the breakpoint. When the breakpoint is hit, both the XSLT and Java stack frames will be displayed in the Debug view. The top XSLT stack frame will be selected and you can inspect the XSLT source and variables.
  3. If you want, you can also click on the Java stack frame that called the XSL transformation and inspect the Java source and variables. You can then step in the XSL transformation and use typical XSL transformation debugging features (as if you were debugging a standalone XSL transformation). You can also step into and debug Java extension calls as described in Debugging Java extensions called from XSL transformations.
  4. To return to the calling Java method, issue a step return from the first template rule.

Results

An alternative method for debugging an XSL transformation called from Java is to use step-by-step debugging. See the Using step-by-step debugging when debugging XSLT section for details.

Note: If the stylesheet or input document is generated (in the case of DOMSource or SAXSource input), the XSLT or XML source is not available before the transformation. You have to use step-by-step debugging in order to stop in the XSLT source.

Feedback