Creating a working stylesheet may seem like an end in itself, but once its written you may want it to run faster or you may not be sure that the output is correct (And if you are sure, how sure are you?).
Profilers, unit test frameworks, and other tools of conventional programming are similarly available for XSLT but are not widely used. This presentation surveys the available tools for ensuring the quality of your XSLT.
There is no one-size-fits-all solution when looking for tools. For example, if you are using Saxon and Ant, then you are looking for a different set of tools than if you are using libXSLT and Makefiles.
This hands-on training is for people familiar with XSLT – either XSLT 1.0 or XSLT 2.0 – who want to improve the reliability and accuracy of their stylesheets.
Attendees must bring their own computer with working XSLT processor and text editor of their choice.
Overview of XSLT testing tools
Overview of the categories of XSLT and XSL FO testing tools
Review: XSLT profilers
More detailed look at XSLT profilers and some of the potential for inaccuracy in the reported results
Demonstration: XSLT profilers
Demonstrate three XSLT profiling tools:
The demonstrations will show how the profilers work, but will also demonstrate that different XSLT processors can have different hotspots.
Exercise 1: Profiling
Attendees will use their choice of one of the three profilers to speed-up a correct but deliberately slow XSLT stylesheet.
(This will also be the flush out the first set of system setup problems with the attendees’ computers. Conversely, anyone who finishes quickly will be invited to try a second profiler.)
Review: XSLT unit testing frameworks
A look at the available XSLT unit testing frameworks and their differing technologies and differing approaches.
Demonstration: XSLT unit testing frameworks
Demonstrate three XSLT unit testing frameworks in action:
Exercise 2: Running unit test framework
Attendees will run the unit testing framework of their choice on existing unit tests for the stylesheets in exercise 1, both the original version and the sped-up version.
Exercise 3: Extending unit tests
Attendees will extend the unit tests to test additional templates and conditions not covered by the existing tests.
Additional tests will include both “clean” tests and “dirty” tests, where the template is supposed to throw an error.
Exercise 4: Extending XSLT
Attendees will extend the stylesheet and write unit tests to verify the changes—or they might write tests to verify the changes and extend the stylesheet until it passes.
Demonstration: XSLV Static Validation tool
Introduction to the XSLV static validation tool.
Exercise 5: Static validation
Validate stylesheets from profiling and unit test exercises.
There will be errors to be found in the original stylesheet, and there may be more errors to be found in the modified stylesheets.
Review: Errors not caught by unit testing or static validation
Review of the types of errors – misleading comments, off-by-one errors, empty #PCDATA, etc. – that are not caught by either unit testing or static validation.
Exercise 6: Eyeballs
The stylesheets the attendees have been using will have contained several errors that either would not have been caught by unit tests or static validation or could have been caught if attendees had written more unit tests.
The attendees will be invited to find additional errors. It is expected that different people will find different errors, and it is even possible that previously unknown errors will be found.
Concluding Remarks
Review of the tools and their strengths and weaknesses.
Tony Graham is an independent consultant specialising in XSL, XSLT, and XML. He has been working with markup since 1991, with XML since 1996, and with XSL/XSLT since 1998.
Tony is an invited expert on the W3C XSL FO subgroup and a previous member of the W3C XML Protocol WG. He is the author of Unicode: A Primer and the developer of the xmlroff XSL Formatter. He is a member of the XML Guild.
Tony is interested in applying the tools for ensuring software quality unit testing, code coverage, profiling, and other tools to XML and XSL/XSLT processing.