In this chapter, we will build on Chapters 1 and 2 to provide you with enough information to start building useful XSLT stylesheets. I will introduce a number of the elements that make up the language, providing examples of their use. We will also look at a few of the functions built into the language and see how XSLT manages namespaces, whitespace and some other important issues.
To illustrate the concepts I introduce, we will work mainly with two documents, one that is textual in content, and one that is more data oriented. The former is a Shakespeare play (Hamlet), and the latter is a book catalog that could, for example, have been extracted from a relational database. Both documents are given in the code download for the chapter.
By the end of the chapter, you will:
q have a clearer picture of the processing model of XSLT
q know the difference between push and pull model stylesheets, and when to use each
q understand the use of the most important XSLT elements
q understand the use of a few of the built-in functions
q understand the basic rules of how XSLT copes when there are conflicts in the stylesheet
q know more about the built-in template rules and how to over ride them
Before delving into the detail of XSLT elements and functions, let's start by looking in detail at how an XSLT processor, such as XT, Saxon or MSXML3, processes a document. We will look at the model from an abstract view – becoming an XSLT processor ourselves and working our way through a document and stylesheet. We'll then look at the two fundamental ways in which this model can be used.
More information on these processors can be found in Appendix E. Later in this chapter I will be mainly using XT to process XSLT stylesheets, but any of these processors can be used. XT is similar in use to Instant Saxon, which was introduced in Chapter 2.