XSL defines a number of top-level elements that can be direct child elements of <xsl:stylesheet> :
<xsl: namespace-alias >
<xsl: preserve-space >
<xsl: strip-space >
The XSLT 1.1 working draft adds one more top-level element:
Youll 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="http://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 youll 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="http://www.w3.org/1999/XSL/Transform"> <xsl:template> . . . </xsl:template> . . .
Creating and using templates is the very heart of XSLT, and Ill take a look at that element next , as we continue writing planets.xsl.