I have a Java servlet which generates xml, translates it with an xslt stylesheet, and then displays the resulting HTML. This is the first time I've worked with xslt. What's a good way to debug xslt? I have (or can get) some sample XML files to apply the transform too. But I'm not really even sure of the syntax so something that would give me syntax warnings would be great.
To start debugging an XSLT applicationPress F11 to step into the XSLT code. The XSLT style sheet is loaded in a new document window and the XSLT debugger starts. Alternatively, you can add a break point to the style sheet and run your application.
XSLT debugging is handled by the eclipse platforms debugging framework support as outlined in the "Program Debug and Launch Support". Common operations like stepping into (F5), stepping over (F6), pausing, running to a breakpoint, and relaunching are supported.
Prior to initiating an XSLT or XQuery transformation, click the “Enable Back-mapping” button on the XMLSpy toolbar. XMLSpy will give you the option to tile the source and output documents so you can easily visualize related elements in one window. Then, run the transformation.
Select the XSL and XML files you want to work with and click Debug > XSL Transformation from the pop-up menu. If you want to transform an XML file or debug an XSL file and indicate specific information about the transformation or debugging process, you should create a Run or Debug configuration.
If you want to do "printf-style" debugging and don't want to litter your output with debugging data, use the <xsl:message>
tag to generate debugging output while processing the stylesheet. With the terminate="yes"
attribute you can even halt the processing of the stylesheet.
Xalan should give you useful errors when you try to use an invalid XSLT. If you want something more powerful, one option for debugging XSLT is Oxygen XML Editor. It is integrated with Xalan and Saxon transform engines. Its debugging mode allows you to set breakpoints, watch variables, and provides other such basic debugging functionality. It may be overkill for you want, but it's very good.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With