<xsl:stylesheet>  
The root element of an XSLT stylesheet. It is identical to the <xsl:transform> element, which was included in the XSLT specification for historical purposes.
 
Category

Contains the entire stylesheet

 
Required Attributes
version
Indicates the version of XSLT that the stylesheet requires. For XSLT version 1.0, its value should always be " 1.0 " . As later versions of the XSLT specification are defined, the required values for the version attribute will be defined along with them.

xmlns:xsl
Defines the URI for the XSL namespace. For XSLT Version 1.0, this attribute's value should be http://www.w3.org/1999/XSL/Transform . Note that most XSLT processors will give you a warning message if your xmlns:xsl declaration does not have the proper value.

 
Optional Attributes
id
Defines an ID for this stylesheet.

extension-element-prefixes
  • Defines any namespace prefixes used to invoke extension elements. Multiple namespace prefixes are separated by whitespace.

  • exclude-result-prefixes
    Defines namespace prefixes that should not be sent to the output document. Multiple namespace prefixes are separated by whitespace.

     
    Content

    This element contains the entire stylesheet. The following items can be children of <xsl:stylesheet>:

      <xsl:import>

      <xsl:include>

      <xsl:strip-space>

      <xsl:preserve-space>

      <xsl:output>

      <xsl:key>

      <xsl:decimal-format>

      <xsl:namespace-alias>

      <xsl:attribute-set>

      <xsl:variable>

      <xsl:param>

      <xsl:template>

     
    Appears in

    None. <xsl:stylesheet> is the root element of the stylesheet.

     
    Defined in

    XSLT section 2.2, Stylesheet Element.

     
    Example

    For the sake of completeness, we'll include an example here. We'll use the Hello World document from the XML 1.0 specification for our example:

    <?xml version="1.0"?>
    <greeting>
      Hello, World!
    </greeting>

    We'll transform our document with this stylesheet:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output method="html"/>
    
      <xsl:template match="/">
        <xsl:apply-templates select="greeting"/>
      </xsl:template>
      
      <xsl:template match="greeting">
        <html>
          <body>
            <h1>
              <xsl:value-of select="."/>
            </h1>
          </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>

    When we transform our document with this stylesheet, here are the results:

    <html>
    <body>
    <h1>
      Hello, World!
    </h1>
    </body>
    </html>