Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project


   







ELEMENT:  xsl:stylesheet

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

 
The xsl:stylesheet element contains all other XSLT elements and delimits the start and stop of the code in an .xsl program. No other XSLT element can occur before the opening xsl:stylesheet element, nor may any other XSLT element occur after the closing xsl:stylesheet element.
 
A direct comparison can be made between the opening and closing <html> ... </html> tags of the HTML language, in that both the html tag and the xsl:stylesheet element serve as delimiting containers for all other members of their respective languages.
 
An important duty performed by the xsl:stylesheet element is that it must contain the XSLT namespace declaration. The purpose of the namespace declaration is to declare that the document is an XSLT stylesheet. Use the following syntax:
 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
Older, proprietary versions of Microsoft XSLT used the following namespace:
 
xmlns:xsl="http://www.w3.org/TR/WD-xsl"
 
The xsl:stylesheet element is also commonly referred to as the root element of the stylesheet. Since it is the root, there can be no other element that is a parent to the xsl:stylesheet element. All other XSLT elements are either children, grandchildren, or further descendants. Only the following eight XSLT elements can be children:
 
  • xsl:attribute-set
  • xsl:import
  • xsl:include
  • xsl:output
  • xsl:param
  • xsl:script
  • xsl:template
  • xsl:variable

  •  
    The xsl:transform element performs the exact same purpose as the xsl:stylesheet element. These two elements may be used interchangeably. They are considered synonymous with each other.
     
    This is not a self-closing element. The separate closing element is mandatory.
     
    version="version_number"
     
    The mandatory version attribute is set to the version number. Currently, the version number is "1.0".
     
    id="unique_id"
     
    The optional id attribute is a unique identifier for the stylesheet. This allows the stylesheet to be referenced in another XML document.
     
    exclude-result-prefixes="list"
     
    The optional exclude-result-prefixes attribute is a list, delimited by white-space, of the namespaces prefixes that should not be copied into the output (the result tree).
     
    extension-element-prefixes="list"
     
    The optional extension-element-prefixes attribute is a list, delimited by white-space, of the namespaces prefixes used for extension elements.
     
    We use the DevGuru Staff List XML file for our example with the following header:
    <?xml-stylesheet type="text/xsl" href="xslt_example_stylesheet.xsl"?>
    and we name it: xslt_example_stylesheet.xml
     
    Code for xslt_example_stylesheet.xsl:
     
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
    <html>
    <body>
    <xsl:for-each select="devguru_staff/programmer">
    <div>
    NAME: <xsl:value-of select="name" />
    <br />
    DOB: <xsl:value-of select="dob" />
    <br />
    AGE: <xsl:value-of select="age" />
    <br />
    ADDRESS: <xsl:value-of select="address" />
    <br />
    PHONE: <xsl:value-of select="phone" />
    <hr />
    </div>
    </xsl:for-each>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

     
    Output:
     
    Click to view output in separate window - requires Internet Explorer

     
     


    Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
    Trademark Information