Chapter 3: Stylesheet Structure


Overview

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.

  • 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 <xsl:stylesheet> or <xsl:transform> element. The full specifications are in Chapter 5.

  • A brief description of each instruction that can be used in a stylesheet. In the previous chapter, I introduced the idea of a sequence constructor as a sequence of instructions that can be evaluated to produce a sequence of items, which will usually be nodes to be written to the result tree. This section provides a list of the instructions that can be used, with a quick summary of the function of each one. Full specifications of each instruction can be found in Chapter 5.

  • Simplified stylesheets, in which the <xsl:stylesheet> and <xsl:template match="/"> elements are omitted, to make an XSLT stylesheet look more like the simple template languages that some users may be familiar with.

  • Attribute value templates. These define variable attributes not only of literal result elements, but of certain XSLT elements as well.

  • Facilities allowing the specification to be extended, both by vendors and by W3C itself, without adversely affecting the portability of stylesheets.

  • Handling of whitespace in the source document, in the stylesheet itself, and in the result tree.

Chapter 4 concludes the introductory section of this book with a discussion of how schemas are used with XSLT. The main reference section of the book then follows in Chapters 5 through 8.




XSLT 2.0 Programmer's Reference
NetBeansв„ў IDE Field Guide: Developing Desktop, Web, Enterprise, and Mobile Applications (2nd Edition)
ISBN: 764569090
EAN: 2147483647
Year: 2003
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net