WebReference.com - Excerpt from Inside XSLT, Chapter 2, Part 2 (5/5)
[previous] |
Inside XSLT
Top-Level Stylesheet Elements
XSL defines a number of top-level elements that can be direct child
elements of <xsl:stylesheet>
:
<xsl:attribute-set>
<xsl:decimal-format>
<xsl:import>
<xsl:include>
<xsl:key>
<xsl:namespace-alias>
<xsl:output>
<xsl:param>
<xsl:preserve-space>
<xsl:strip-space>
<xsl:template>
<xsl:variable>
The XSLT 1.1 working draft adds one more top-level element:
<xsl:script>
You'll see all these official top-level XSLT elements in this book.
Note that in addition to all these top-level elements, you can also use normal XML comments throughout, because XSLT stylesheets are also XML documents:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="https://www.w3.org/1999/XSL/Transform">
<!-- This template matches all PLANETS elements -->
<xsl:template match="/PLANETS">
<HTML>
<HEAD>
.
.
.
In addition to the official top-level elements, several XSLT processors define their own top-level elements, and those elements use namespaces that are not the same as the XSL namespace. What these implementer-defined top-level elements do is up to the creator of the XSLT processor.
You can also define your own top-level elements, called user-defined top-level elements. These elements must have a different namespace from XSL and implementer-defined top-level elements. The XSLT processor ignores user-defined top-level elements, but because you can gain access to the whole document yourself with the document function (which you'll see in Chapter 8), you can make use of these elements yourself.
Of all the top-level elements, the most popular is the
<xsl:template>
element:
<?xml version="1.0">
<xsl:stylesheet version="1.0" xmlns:xsl="https://www.w3.org/1999/XSL/Transform">
<xsl:template>
.
.
.
</xsl:template>
.
.
.
Creating and using templates is the very heart of XSLT, and I'll take a look at that element next, as we continue writing planets.xsl.
[previous] |
Created: September 20, 2001
Revised: September 20, 2001
URL: https://webreference.com/authoring/languages/xml/insidexslt/chap2/2/5.html