June 13, 2013

XSLT Debugging with Altova XSLT Spy

​Debugging XSLT with Altova XMLSpy
Testing and perfecting XSLT stylesheets can be a complicated, time-consuming process. With the XMLSpy XSLT debugger, you can step through and debug even the most intricate stylesheets quickly and easily. You can even debug stylesheets that contain program code in Java, C#, JavaScript, or VBScript. When debugging complex XSLT stylesheets, it is useful to be able to understand exactly what output is produced by each instruction. In the XSLT debugger, you can define breakpoints in the XML and XSLT files, and tracepoints in the XSLT document.

Setting Breakpoints & Tracepoints
Breakpoints halt the XSLT debugger when a particular node, element, or attribute is accessed by an XSLT instruction, allowing you to view the output to that particular point in the transformation. When you start the debugger, the XSLT processor stops at the first breakpoint and displays all data relevant to the node in the debugger info windows.
In contrast to breakpoints, tracepoints do not halt the XSLT debugger. When a tracepoint is hit during an XSLT debugging session, the instruction is executed, and information is written to the Trace window. Once the transformation is complete, the trace window displays the list of tracepoints as well as the output produced by each. This allows you to view exactly how each XSLT instruction is executed.

  • Open the XSLT File in Altova XMLSpy Edito
  • Specify the output XML file
  • Insert break point/Trace point at desired node, attribute or element
  • Review the output in output window
Eg. Search Core Result Web part XSLT Debugging
  • To debug the XSLT, you will need the output XML file. So edit the search core result web part
  • Click on XSL Editor under ‘Display Properties’
  • Copy-Paste following code in editor:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
    <xmp><xsl:copy-of select="*"/></xmp>
  • Copy the output and save it in an XML File say output.xml
  • Open the XSLT file with Altova XMLSpy editor
  • Set breakpoint/trace point to attribute/node/element
  • Click on XSL/Query menu and select Start Debugger/Go
  • Specify the output.xml file location
  • Start debugging!!!!

If you have any questions you can reach out our SharePoint Consulting team here.

No comments:

Post a Comment