XML technologies / XSLT / XSLT Cookbook / Testing and debugging

(Excerpt from “XSLT Kochbuch” by Sal Mangano)

“A crash often produces a message like ‘ID 02’.
‘ID’ stands for idiosyncrasy,
and the number is how many months
the product still needed testing.”

Guy Kawasaki

Introduction

Many XSLT scripts for well-defined inputs are used only once. Testing then consists of running the transformation and inspecting the result. Even here, ask what to do if the stylesheet misbehaves. Often, inspecting code reveals the cause. For developers new to XSLT, however, visual inspection for debugging is often ineffective, even with experience in procedural XML processing. This chapter therefore introduces basic debugging methods to resolve common coding errors faster and improve XSLT skills.

This book emphasizes reusable XSLT. Reusable code needs more thorough testing because it will run in environments its author cannot fully know. Ensure expected behavior for typical inputs and boundary conditions, and predictable behavior for invalid input.

Easier testing encourages developers to test. Interpreted languages such as XSLT are usually easier because there is no compile/link cycle. XSLT also has identical language and data syntax ( homoiconic). Thus, test data can be embedded directly in a stylesheet, making self-contained tests.

These recipes use only XSLT facilities. Still, nothing beats a real debugger. Here are commercial products; I have not tried them all, so this is not an endorsement. Many do more than debug XSLT:

  • Active States Visual XSLT 2.0

  • Altova XML Spy version 2005

  • Emacs-based XSLT debugger: XSLT-process

  • Exchanger

  • MarrowSoft Xselerator 2.6

  • Oxygen

  • Stylus Studio 6

  • WebSphere Studio Application Developer

Treebeard is an open-source project written in Java, working with the XSLT processors in Xalan, Saxon, jd and Oracle. It is more a visual XSLT development environment than a full debugger, but helps investigate XPath expressions.

  

  

 

 

 

back to top