XSLT Tutorial

 

Table of Contents

Debugging the Program

In this step you will add breakpoints to the program and "debug" it. Adding breakpoints lets you to run the program in chunks, making it easier to watch variables and view output as it is generated.

  1. Assign the XML input file If necessary, click on the "mailexport2html.xsl" tab in the editor. Below the Editor pane, click Choose File... and select "mailexport.xml" (unless the input file was assigned in the previous step). By assigning the XML input file to the XSLT program file, the Komodo editor will divide horizontally so that both files can be displayed. Also, when you run the transformation, the XML file will be selected by default as the input file.
  2. Step Into Select Debug|Step Into (or <F11>, or use the Debug Toolbar). In the Debugging Options dialog, click OK to accept the defaults.

Komodo Tip Debugger commands can be accessed from the Debug menu, by shortcut keys, or from the Debug Toolbar. For a summary of debugger commands, see Debugger Command List.

  1. Watch the debug process A yellow arrow on line 6 indicates the position in the XSLT file where the debugger has halted. Another yellow arrow on line 1 in the XML file indicates the processing point in the input file.
  2. View the Variables tab On the Output Pane, click the Variables tab. On the Locals tab, notice that the current Call Stack is the template in line 6 of the XSLT program. The Locals tab displays a nested data structure of all the nodes in the XML document.
  3. Set a breakpoint On the "mailexport2html.xsl" pane, click on the grey margin immediately to the left of the code on line 12. This will set a breakpoint, indicated by a red circle.

Komodo Tip Breakpoints can be set at any time. When the debugger is not running, breakpoints are displayed as green circles. When the debugger is running, they are displayed as red circles.

  1. Step Out Select Debug|Step Out. The debugger will run until it encounters a breakpoint; if no breakpoint had been set, the debugger would run until the end of the program.
  2. Step Into Select Debug|Step Into. Notice that the debugger jumps to line 33 of the XSLT program, and advances the pointer in the XML file to line 4. When the debugger processed line 12 (xsl:apply-templates), it looked for a template that matched the top node in the XML document (<EMAILCOMMENTS>). When no matching template was found, it proceeded to the next node in the XML document (<EMAIL>) and found a matching template on line 33.
  3. View the Output tab The HTML tags on lines 7 to 11 of the XSLT program have been written to the Output pane.
  4. View the Variables tab Notice that the Call Stack displays the current template; previous templates can be selected from the drop-down list.
  5. Step Into to line 20 Use the Step Into command until the current-line pointer in the XSLT file is on line 20.
  6. Step Into to line 21 Watch the Output pane as you Step Into line 21. The xsl:value-of statement will select the contents of the <SUBJECT> field on line 9 of the XML file and place it within the HTML tags on lines 19 and 21.
  7. Step Into to line 22 Line 22 will call the template "formatEmail" on line 45, and process it with the "address" parameter on line 46. This routine will process the contents of the <ORIGADDRESS> node in the XML document. In order to generate the hyperlink in the output HTML document, lines 48 and 49 concatenate the string "mailto:" with the contents of the <ORIGADDRESS> node.
  8. Stop the Debugger Select Debug|Stop to stop the Komodo Debugger.

Top Previous Next