XSLT



         


computer science, XSLT is the abbreviation for Extensible Stylesheet Language Transformations. It is a part of the XSL specification and is a language for transforming XML documents.

XSLT is a XML transformation language, which transforms documents in XML format. To transform in this context means to take all data or part of it (Query of a selection with XPath) and create another XML document or a document in a format which can directly be used for displaying or printing (e.g. an HTML, RTF or TeX document). In particular the transformations involve:

An XML document is a tree on which the transformations are applied. The language is declarative, i.e. a program consist of a collection of several rules which transformations should be performed. The rules are applied recursively.

The XSLT processor checks which rules can be applied and executes the associated transformations based on a sequence of priorities.

You can use XSLT in combination with CSS to produce HTML documents.

An XSLT program is an XML document as the following template shows

<?xml version="1.0" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> ... </xsl:stylesheet>

STX is intended as a high-speed, low memory consumption alternative to XSLT.

[Top]

Example

This example is taken from .

Example: A function calculating factorial as an example of XSLT recursion. Note that xsl:function is part of XSLT 2.0, which is not yet a finished W3C Recommendation.

<xsl:function name="eg:fact"> <xsl:param name="n"/> <xsl:choose> <xsl:when test="$n = 1 or $n = 0"> <xsl:value-of select="1"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$n * eg:fact($n - 1)"/> </xsl:otherwise> </xsl:choose> </xsl:function>
[Top]




  View Live Article   This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License