How to Debug XSLT and XQuery


Nothing’s more frustrating than getting unintended results from an XSLT or XQuery transformation and having to spend hours tracking down the issue – especially if you’ve inherited the project from another developer or haven’t looked at the code in a few months.  Of course, XMLSpy has long included an XSLT debugger and XQuery debugger for setting break points and stepping through transformations to identify problems. However, the debugging process just got even more interactive and precise with the introduction of XSLT/XQuery back-mapping.

With back-mapping enabled, you can simply click on or hover over the portion of your output document you want to zero in on, and XMLSpy will immediately highlight the source XML and XSLT or XQuery instruction that is responsible. Let’s see how it works.

Debug XSLT with back-mapping

Debugging XSLT and XQuery with Back-mapping

Prior to initiating an XSLT or XQuery execution, click the “Enable Back-mapping” button on the XMLSpy toolbar.

 

Debugging with XQuery back-mapping

 

XMLSpy will give you the option to tile the XML, XSLT or XQuery, and output documents so you can easily visualize related elements in one window. In the XSLT transformation shown below, we can hover over any section of the output in Browser view, and XMLSpy automatically highlights the source node and instruction in the XML and XSLT documents for immediate debugging.

 

Debug XSLT with back-mapping

The process works the same in Text View for XSLT and XQuery output – simply select the portion of the output document you need to analyze.

The ability to simply click into your output to identify its source is a huge time saver for testing and debugging XSLT and XQuery code. Best of all, XMLSpy accomplishes back-mapping without modifying your output document in any way.

See how this works for both XSLT and XQuery in this quick back-mapping video.

 

 

XSLT/XQuery back-mapping is available starting in XMLSpy Version 2017 Release 3. Update to the latest version now or try it free for 30 days.

 

 

Tags: , , , , , , , ,