Most XSLT looks more or less like ordinary XML. Simple XSLT stylesheets are merely a specialized form of XML markup designed for specifying the transformation of other XML documents. You can think of XSLT as just another document type.
A stylesheet that transforms a document into another XML document might have a root element that looks like Example 18-1.
Example 18-1. XSLT stylesheet using XML output elements
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml"/> <!-- template rules go here --> </xsl:stylesheet>
The root element is xsl:stylesheet.[2] It must have a namespace declaration for XSLT. It makes sense to use the same declaration and xsl: prefix every time. You can also specify the output method to be used by the processor, choosing between XML, HTML and plain text.
[2] The space also allows the root element to be called xsl:transform, presumably for the benefit of people with no style sense!
The xsl:stylesheet element is usually filled with template rules. The template rules describe how to transform elements in the source document. Of course almost every element type could be processed differently from every other element type so there are many rules in an XSLT stylesheet. Particular elements could even be processed differently if they share a type but have different attributes or occur in a different context.