Chapter 3. Stylesheet Structure

This chapter describes the overall structure of a stylesheet. In the previous chapter we looked at the processing model for XSLT and the data model for its source and result trees. In this chapter we will look in more detail at the different kinds of construct found in a stylesheet such as declarations and instructions, literal result elements, and attribute value templates.

Some of the concepts explained in this chapter are tricky; they are areas that often cause confusion, which is why I have tried to explain them in some detail. However, it's not necessary to master everything in this chapter before you can write your first stylesheet — so use it as a reference, coming back to topics as and when you need to understand them more deeply.

The topics covered in this chapter are as follows:

  • Stylesheet modules. We will discuss how a stylesheet program can be made up of one or more stylesheet modules, linked together with <xsl:import> and <xsl:include> elements.

  • The <xsl:stylesheet> (or <xsl:transform> element). This is the outermost element of most stylesheet modules, and it defines various attributes that control how other constructs in the module behave.

  • The <?xml-stylesheet?> processing instruction. This links a source document to its associated stylesheet, and allows stylesheets to be embedded directly in the source document whose style they define.

  • A brief description of the declarations found in the stylesheet, that is, the immediate children of the ...

Get XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.