Chapter 22. XSLT

As everybody (who is not completely immune against any IT industry hype) knows, XSLT is the transformation language for XML, the extensible markup language. Why do we tackle such a transformation language in a book about general purpose programming languages? First, of course, it adds a few million people to the potential audience for this book. More seriously, I realized when using XSLT for larger projects that programming XSLT is quite different from the kind of (mostly object-oriented) programming I was used to. Some things become very easy and others extremely tedious.

XSLT ows part of its expressiveness to the powerful XML query language XPath which we will therefore cover to some extent as well.

22.1. Software and Installation

There are many good open source libraries for XSLT available for several languages (most notably for the C-family C, C++, Java, C#). For the examples in this chapter, you can use any of these tools. Because of its simplicity and speed, I have used xsltproc, the command line interface for the fast XSLT library libxslt written in C. Both, the library and the command line tool are part of every Linux distribution, but are also available as binaries for the Win32 platform.

References

The best book on XML and XSL I know is also one of the shortest: the XSLT pocket reference. About half of the book (that is, just 50 pages) covers XSLT and XPath. If you want (or need) to spend more time on XSLT, have a look at [KAY03]>, written by the developer of the Saxon XSLT processor (who therefore must know XSLT in and out).

Robert Eckstein and Michel Casabianca, 0596001339, O'Reilly, 2001, XML Pocket Reference: Second Edition.

Michael Kay, 0764543814, John Wiley, 2003, XSLT: Second Edition.