Microsoft XML SDK 2.6 - XSLT Reference

xsl:stylesheet Element

The document element of a style sheet, containing all other stylesheet elements.

<xsl:stylesheet
  id = "id"
  extension-element-prefixes = "prefixes"
  exclude-result-prefixes = "prefixes"
  version = "number">
</xsl:stylesheet>

Attributes

version
Required. Indicates the version of XSLT the style sheet requires. Value should be set to 1.0 for this version of XSLT.
id
Specifies a unique identifier to facilitate embedding stylesheets.
extension-element-prefixes
Designates a namespace as an extension namespace. The value is a white-space separated list of namespace prefixes. The namespace bound to each of the prefixes is designated as an extension namespace. The default namespace (as declared by xmlns) may be designated as an extension namespace by including #default in the list of namespace prefixes. The designation of a namespace as an extension namespace is effective within the subtree of the stylesheet rooted at the element bearing the extension-element-prefixes; a subtree rooted at an xsl:stylesheet element does not include any stylesheets imported or included by children of that <xsl:stylesheet> element.
exclude-result-prefixes
Designates a namespace URI as an excluded namespace. The value is a white-space separated list of namespace prefixes. The namespace bound to each of the prefixes is designated as an excluded namespace. The default namespace (as declared by xmlns) may be designated as an excluded namespace by including #default in the list of namespace prefixes. The designation of a namespace as an excluded namespace is effective within the subtree of the stylesheet rooted at the element bearing the exclude-result-prefixes; a subtree rooted at an xsl:stylesheet element does not include any stylesheets imported or included by children of that <xsl:stylesheet> element.

Element Information

Number of occurrences One
Parent elements (No parent elements)
Child elements xsl:include, xsl:output, xsl:param, xsl:template, xsl:variable,msxsl:script

Remarks

A style sheet contains the <xsl:stylesheet> element. This element can have a set of <xsl:template> elements representing different output templates. Processing begins by processing the root template, indicated by the pattern "/".

Example

This example shows a complete XSLT style sheet that contains a set of templates. The root template (match="/") defines the structure of the overall output document, and the other templates define the structure of the name, address, and phone elements.

<?xml version="1.0" ?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <HTML>
      <BODY>
        <TABLE>
          <xsl:for-each select="customers/customer">
            <TR>
              <xsl:apply-templates select="name" />
              <xsl:apply-templates select="address" />
              <xsl:apply-templates select="phone" />
            </TR>
          </xsl:for-each>
        </TABLE>
      </BODY>
    </HTML>
  </xsl:template>
  <xsl:template match="name">
    <TD STYLE="font-size:14pt font-family:serif">
      <xsl:apply-templates />
    </TD>
  </xsl:template>
  <xsl:template match="address">
    <TD> <xsl:apply-templates /> </TD>
  </xsl:template>
  <xsl:template match="phone">
    <TD> <xsl:apply-templates /> </TD>
  </xsl:template>
  <xsl:template match="text()"><xsl:value-of /></xsl:template>
</xsl:stylesheet>