O'Reilly logo

Beginning XSLT and XPath: Transforming XML Documents and Data by Ian Williams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10. Debugging, Validation, and Documentation

Quite often the stylesheets that you write are for simple (and sometimes one-off) projects. You can just run the transform and inspect the results until it works correctly. If you hit a problem, you can inspect the code and fix it. Sometimes, however, the solution to a problem is not obvious.

Any good XSLT development environment will provide useful debugging features to help you locate problems in your code. Typically, you can step through code, set breakpoints, inspect variables, and trace execution. Then, XSLT itself provides inline messaging and error-tracing features.

Until quite recently it was not possible to validate either source or result documents within an XSLT processor. Validation, apart from passing or failing the document concerned, can help you identify stylesheet errors that you might otherwise find difficult to find, or even miss entirely.

Systematic documentation is often delivered only with the largest and most established projects. However, it is very easy to add documentation to a stylesheet and process it using XSLT.

In this chapter you'll do the following:

  • Experiment with the XSLT Debugger in the Oxygen IDE.

  • Write trace text with <xsl:message> and <xsl:comment>.

  • Survey the features of two XPath error-handling functions.

  • Learn to validate both output and input in your stylesheets using the schema-aware version of the Saxon processor.

  • Use XSLTdoc, an open-source package that makes inline documentation a snap.

Debugging ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required