10.6. XSLT Style Sheet StructureThe general order for elements in an XSL style sheet is as follows: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:import/> <xsl:include/> <xsl:strip-space/> <xsl:preserve-space/> <xsl:output/> <xsl:key/> <xsl:decimal-format/> <xsl:namespace-alias/> <xsl:attribute-set>...</xsl:attribute-set> <xsl:variable>...</xsl:variable> <xsl:param>...</xsl:param> <xsl:template match="..."> ... </xsl:template> <xsl:template name="..."> ... </xsl:template> </xsl:stylesheet> Essentially, this ordering boils down to a few simple rules. First, all XSL stylesheets must be well-formed XML documents, and each <XSL> element must use the namespace specified by the xmlns declaration in the <stylesheet> element (commonly xsl:). Second, all XSL stylesheets must begin with the XSL root element tag, <xsl:stylesheet>, and close with the corresponding tag, </xsl:stylesheet>. Within the opening tag, the XSL namespace must be defined: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> After the root element, you can import external stylesheets with <xsl:import> elements, which must always be first within the <xsl:stylesheet> element. Any other elements can then be used in any order and in multiple occurrences if needed. Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|