Although the idea behind Extensible Stylesheet Language for Transformations (XSLT) is simple, putting it into practice can be difficult, in part due to the number of attendant abbreviations and acronyms: XSL, XPath, etc. Furthermore, the available introductory material on XSLT suffers from the same weakness as introductory XML material in general in assuming that the reader is intimately familiar with analogous HTML technologies.
The back cover of XSLT Developer’s Guide, from Osborn/McGraw Hill, promises just the advice you need to implement XSLT in a real-world application. If you came across this title in a bookstore and began browsing its first few chapters, you might be tempted to put it back on the shelf and look elsewhere. That would be a mistake.
Don’t judge a book by its beginning
The book starts off on the wrong foot. XSLT Developer’s Guide begins with three chapters dedicated to the history of XML and the basic ideas behind the technology. Certainly, a fundamental understanding of XML is an important prerequisite for any discussion of XSLT, and I would welcome such a technology overview in XSLT Developer’s Guide. Instead, the authors devote 61 pages to explaining how SGML begat HTML, which in turn begat XML.
While such a taxonomic discussion might be interesting to some, I found these first chapters dry, of little practical value, and even a little confusing. During the chapter’s recitation of the history of XML, the authors routinely refer to bits of technology as if they expect the reader to know what they mean. This is especially true in chapter two, inappropriately named “An Introduction to XSLT.” This chapter makes repeated references to comparatively advanced aspects of XSLT without referring to later sections of the book, where more information can be found.
These first few chapters probably began life as an appendix that was transformed into an introduction, and were never intended to be an XML tutorial. If they were, the authors missed the mark. Consider these first three chapters to be just so many unnecessarily dead trees and skip them, or better yet, tear them out and recycle them. This book really begins in chapter four.
The beginning after the beginning
Once you’ve skipped to chapter four, “The Structure of an XLST Stylesheet,” XSLT Developer’s Guide looks much better. The next two chapters are devoted to a very sound introduction to XSLT’s syntax and structure. The book takes a teach-by-example approach, walking the reader through multiple examples that explain why things work instead of just how to use them. The only area that could have used more direct attention is the way XSLT recursively processes documents, which is confusing for neophytes. The text repeatedly dances around this issue.
From there, the level gradually becomes more advanced. Chapter seven builds on the basics by showing you how to work with results from a transformation. In the next three chapters, the authors do an excellent job of explaining the programmable nature of XSLT documents, which is something few introductory resources I’ve seen delve very far into. Beginning with the basics of variable and parameter use in chapter eight and continuing all the way up to “power programming” tips on result sorting and formatting in chapter 10, this section provides a comprehensive introduction to XSLT as a programmable language, backed up with copious examples.
You’ll find two sections early in chapter 11, “Practical XSLT Examples,” that you’ll want to highlight right away. “What type of problem is XSLT well suited for” and “When should XSLT not be used” serve to curb your enthusiastic desire to apply your newfound knowledge to inappropriate areas, and they should be required reading. As you can probably guess by the title of chapter 11, in the final three chapters the book changes gears from technology tutorial to practical application examples. Here, you’ll follow along through numerous examples of XSLT applications, including data manipulation, generation of other XLST documents, the creation of multiple documents from a single XML data document, and large-scale applications of the technology like EAI and reprocessing syndicated content.
The verdict? Worth a look
Leaving the disappointing beginning out of the evaluation, what’s left of XSLT Developer’s Guide is a good, thorough technical book that provides a solid introduction to XSLT. Although they tend to concentrate rather heavily on transforming documents into HTML, which is only part of the story, the authors do an excellent job overall of walking you through the technology and pointing out potential gotchas along the way. XSLT Developer’s Guide is an excellent choice as a how-to and a reference title.