Click to return to the XML (Extensible Markup Language) home page    
xsl:script Element     xsl:template Element     XSL Elements    
Web Workshop  |  XML (Extensible Markup Language)

xsl:stylesheet Element


The document element of a stylesheet, containing xsl:template and xsl:script elements.

Syntax

<xsl:stylesheet
    default-space="preserve"
    indent-result="yes"
    language="language-name"
    result-ns="value"  >

Attributes

default-space
Whether to preserve white space that appears in the source document. Only the value of "default" is supported; other values are ignored.
indent-result
Indicator of whether to preserve in the output any white space that appears in the style sheet. The actual white-space characters themselves can be changed. Only the value "yes" is supported; other values are ignored.
language
Active Scripting language used within this style sheet. The default is JScript® (compatible with ECMA 262 language specification). This attribute accepts the same values as the language attribute on the HTML SCRIPT element.
result-ns
Indicator of what the output of the XSL processor is. In Microsoft® Internet Explorer 5 all output is XML, including well-formed HTML, thus this attribute is ignored.

Element Information

Number of occurrences 1
Parent elements (No parent elements)
Child elements xsl:script, xsl:template
Requires closing tag Yes. XSL is an XML grammar and, like all XML grammars, all tags must have closing tags to satisfy the definition of well-formed.

Remarks

An XSL 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 XSL 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.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  <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

Creating and Populating an HTML Template, Handling Documents and Irregular Data



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.