Wednesday, August 18, 2010


Text are from

  • XSL stands for EXtensible Stylesheet Language.
  • CSS - Style Sheet for HTML
  • XSL - Style Sheet fot XML
  • XSL describes how the XML document should be displayed!

XSL consists of three parts:
  • XSLT - a language for transforming XML documents
  • XPath - a language for navigating in XML documents
  • XSL-FO - a language for formatting XML documents


  • XSLT stands for XSL Transformations
  • XSLT is the most important part of XSL
  • XSLT transforms an XML document into another XML document
  • XSLT uses XPath to navigate in XML documents
  • All major browsers have support for XML and XSLT.

XSLT - Transformation

The root element that declares the document to be an XSL style sheet is <xsl:stylesheet> or <xsl:transform>

<xsl:stylesheet version="1.0" xmlns:xsl="">
<xsl:transform version="1.0" xmlns:xsl="">

example transformation 
Source xml file.

Source XSL Style Sheet file.

Result of transformation.


The <xsl:template> element is used to build templates.

The match attribute is used to associate a template with an XML element. The match attribute can also be used to define a template for the entire XML document. The value of the match attribute is an XPath expression (i.e. match="/" defines the whole document).



The <xsl:value-of> element can be used to extract the value of an XML element and add it to the output stream of the transformation:


The XSL <xsl:for-each> element can be used to select every XML element of a specified node-set:


We can also filter the output from the XML file by adding a criterion to the select attribute in the <xsl:for-each> element.


The <xsl:sort> element is used to sort the output.


The <xsl:if> element is used to put a conditional test against the content of the XML file.


The <xsl:choose> element is used in conjunction with <xsl:when> and <xsl:otherwise> to express multiple conditional tests.


The <xsl:apply-templates> element applies a template to the current element or to the current element's child nodes.
If we add a select attribute to the <xsl:apply-templates> element it will process only the child element that matches the value of the attribute. We can use the select attribute to specify the order in which the child nodes are processed.

No comments:

Post a Comment