Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

XSL Transformations (XSLT) can be used to manipulate, sort, and filter XML data. Many transformations will target well-formed HTML. Well-formed means that any HTML tag can be used, subject to the stricter syntax rules of XML — all start tags are paired with end tags and are nested correctly. Well-formed HTML can be displayed by the browser, or further manipulated by XML tools. The World Wide Web Consortium (W3C) currently has a recommendation for making the next generation of HTML an XML application. W3C XHTML™ 1.0: The Extensible HyperText Markup Language, described in the World Wide Web Consortium Web site describes the benefits of defining well-formed HTML. XSLT is a valuable tool for generating well-formed HTML or other XML files.

XSLT enables you to define templates for your output, into which data from the XML source is delivered. Each template defines a pattern that identifies elements in the source tree and defines the resulting output subtree to be generated. The XSLT transformation processor merges data from the XML source document with the template. By combining a set of template fragments into a style sheet, XSLT can be used to perform data-driven transforms useful for highly irregular XML data and XML documents.

XSLT templates are defined using the following set of XML elements:

XSLT Elements

Element Description

xsl:apply-imports Element

Invokes an overridden template rule.

xsl:apply-templates Element

Directs the XSLT processor to find the appropriate template to apply, based on the type and context of each selected node.

xsl:attribute Element

Creates an attribute node and attaches it to an output element.

xsl:attribute-set Element

Defines a named set of attributes.

xsl:call-template Element

Invokes a template by name.

xsl:choose Element

Provides multiple conditional testing in conjunction with the < xsl:otherwise Element> and < xsl:when Element>.

xsl:comment Element

Generates a comment in the output.

xsl:copy Element

Copies the current node from the source to the output.

xsl:copy-of Element

Inserts subtrees and result-tree fragments into the result tree.

xsl:decimal-format Element

Declares a decimal-format, which controls the interpretation of a format pattern used by the format-number Function.

xsl:element Element

Creates an element with the specified name in the output.

xsl:fallback Element

Calls template content that can provide a reasonable substitute to the behavior of the new element when encountered.

xsl:for-each Element

Applies a template repeatedly, applying it in turn to each node in a set.

xsl:if Element

Allows simple conditional template fragments.

xsl:import Element

Specifies an XSLT style sheet to include.

xsl:include Element

Specifies another XSLT style sheet to include.

xsl:key Element

Declares a named key for use with the keyfunction in XML Path Language (XPath) expressions.

xsl:message Element

Sends a text message to either the message buffer or a message dialog box.

xsl:namespace-alias Element

Replaces the prefix associated with a given name space with another prefix.

xsl:number Element

Inserts a formatted number into the result tree.

xsl:otherwise Element

Provides multiple conditional testing in conjunction with the < xsl:choose Element> and < xsl:when Element>.

xsl:output Element

Specifies options for use in serializing the result tree.

xsl:param Element

Declares a named parameter for use within an xsl:stylesheet Elementor xsl:template Element. Allows specification of a default value.

xsl:preserve-space Element

Preserves white space in a document.

xsl:processing-instruction Element

Generates a processing instruction in the output.

msxsl:script Element

Defines global variables and functions for script extensions.

xsl:sort Element

Specifies sort criteria for node lists selected by xsl:for-each Elementor xsl:apply-templates Element.

xsl:strip-space Element

Strips white space from a document.

xsl:stylesheet Element

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

xsl:template Element

Defines a reusable template for generating the desired output for nodes of a particular type and context.

xsl:text Element

Generates text in the output.

xsl:transform Element

Synonym for xsl:stylesheet Element.

xsl:value-of Element

Inserts the value of the selected node as text.

xsl:variable Element

Specifies a value bound in an expression.

xsl:when Element

Provides multiple conditional testing in conjunction with the < xsl:choose Element> and < xsl:otherwise Element>.

xsl:with-param Element

Passes a parameter to a template.

* Microsoft proprietary extensions to support scripting

See Also