Determining what XSL/XQuery expression generated particular output

In order to quickly spot the XSL templates or XQuery expressions with problems it is important to know what XSL template in the XSL stylesheet or XQuery expression in the XQuery document and what element in the source XML document generated a specified area in the output. Some of the debugging capabilities, for example "Step in" can be used for this purpose. Using "Step in" you can see how output is generated and link it with the XSL/XQuery element being executed in the current source context. However, this can become difficult on complex stylesheets or XQuery documents that generates a large output.

Output to source mapping is a powerful feature that makes this output to source mapping persistent that is you can click on the text from the Output document view and the editor will select the XML source context and the XSL/XQuery element that generated the text.

 

Figure 11.16. Output to Source Mapping

Output to Source Mapping

 
  1. If you are in the Editor perspective switch to the XSLT or XQuery Debugger perspective with one of the actions (here explained for XSLT):

    • PerspectiveDebugger or the toolbar button Debugger

    • DocumentXML DocumentDebug scenario or the toolbar button Debug scenario . This action initializes the Debugger perspective with the parameters of the transformation scenario. Any modification applied to the scenario parameters (the transformer engine, the XSLT parameters, the transformer extensions, etc) will be saved back in the scenario when exiting from the Debugger perspective.

  2. Select the source XML document in the XML source selector of the Control toolbar. In case of XQuery debugging without an implicit source choose the NONE value.

  3. Select the XSL/XQuery document in the XSL/XQuery selector of the Control toolbar

  4. Select the XSLT/XQuery engine in the XSLT/XQuery engine selector of the Control toolbar

  5. Set XSLT/XQuery parameters from the button available on the Control toolbar

  6. Apply the stylesheet or XQuery transformation using the button Run to end available on the Control toolbar:

  7. Inspect the mapping by clicking a section of the output from the Text view tab or from the XHTML view tab of the Output document view to have the XSL/XQuery element and the source context highlighted.

     

    Figure 11.17. XHTML Output Mapping

    XHTML Output Mapping