Chapter 4. An overview of XSLT
And yet, my primer suits me so
I would not choose a book to know
Than that, be sweeter wise;
Might some one else so learned be,
And leave me just my A B C,
Himself could have the skies.
EMILY DICKINSON, The First Lesson
XSLT is a relatively simple but very powerful language. Its power comes not from a plethora of tools or hairy syntax, but from the data model it uses and the very convenient way to access the data. XSLT's data model is a tree of nodes corresponding to the tree of elements and character data in the source XML document, and XSLT's method of accessing this tree of nodes is called XPath.
I can't help singing an ode to XSLTa wonderful, truly data-oriented (as opposed to algorithm-oriented) language where everything Just Works. You must have a good grasp of some basic concepts (admittedly, somewhat unusual from other languages' viewpoint), but after that, most of your code will likely work the first time you run it. XSLT and XPath are so high-level that you can actually think about what you want to do with your data, not how .
This book does not intend to be an XSLT tutorial; there are other excellent books that will help you learn this language in depth (see Bibliography, page 385). This chapter is just a refresher intended to bring you up to date with the latest XSLT developments and focus your attention on those features of the language that are important for building a web site transformation stylesheet.
Attention:Version bump ahead. Currently, most XSLT books and online guides cover XSLT 1.0. However, versions 2.0 of both XSLT and XPath represent a huge advance over 1.0. Processor support will need some time to catch up, but you may want to start poking into 2.0 nowif only because there's so much new ground to cover. A lot of really cool things are only possible with 2.0, and you'll discover very soon how limiting 1.0 is in comparison.
In fact, I started writing this book with the intention to stay within 1.0 territory, with only occasional forays into 2.0. However, as the book progressed (and as the 2.0 Working Drafts stabilized), I found that many examples could be rewritten in a more laconic and expressive way with 2.0 features, and still more very interesting examples are only possible with 2.0.
Accordingly, the chapter starts with a brief history of the language and an illustrated overview ( 4.2 ) of the most important new features in XSLT and XPath 2.0. After that, we'll look at some of the commonly used XSLT extensions ( 4.4 )XSLT 2.0 makes many of them obsolete, but not all.