Partager via


xsl:stylesheet Element

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

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

Syntax

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

Attributes

  • version
    [required] Indicates the version of XSL Transformations (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 style sheets.
  • extension-element-prefixes
    Designates a name space as an extension name space. The value is a white-space separated list of name space prefixes. The name space bound to each of the prefixes is designated as an extension name space. The default name space (as declared by xmlns) may be designated as an extension name space by including #default in the list of name space prefixes. The designation of a name space as an extension name space is effective within the subtree of the style sheet rooted at the element bearing the extension-element-prefixes; a subtree rooted at an xsl:stylesheet element does not include any style sheets imported or included by children of that <xsl:stylesheet> element.
  • exclude-result-prefixes
    Designates a name space Uniform Resource Identifier (URI) as an excluded name space. The value is a white-space separated list of name space prefixes. The name space bound to each of the prefixes is designated as an excluded name space. The default name space (as declared by xmlns) may be designated as an excluded name space by including #default in the list of name space prefixes. The designation of a name space as an excluded name space is effective within the subtree of the style sheet rooted at the element bearing the exclude-result-prefixes; a subtree rooted at an xsl:stylesheet element does not include any style sheets imported or included by children of that <xsl:stylesheet> element.

Element Information

Number of occurrences

One

Parent elements

(No parent elements)

Child elements

xsl:attribute-set, xsl:import, 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="https://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>

See Also

Reference

XSLT Elements