XSLT reference

Useful identity templates

String funciton string-length()

Output xml entities as is

<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>

Handling CDATA XSL can't copy CDATA section as CDATA section. http://sources.redhat.com/ml/xsl-list/2001-05/msg00980.html

XPath's axes http://www.w3schools.com/XPath/xpath_axes.asp

Useful XPath samples

<!-- Return the value of the attribute @name where the text of the textarea element is equal to apostrophe -->
<xsl:value-of select="//textarea[text()='apostrophe']/@name"/>
<!-- Return the value of the attribute @name where the children elements of tr element satisfy the following conditions:
-the text of the td element is equal to Min AND 
-td has input child element which has a name attribute
<xsl:value-of select="//tr/td[text()='Min']/../td/input/@name"/>
<!-- Go down to the path but select the parent node -->
<!-- Find span element where the text() is equals to 'Any Label' and then select its parent div node. -->
<xsl:value-of select="//span[contains(text(), 'Any Label')]/parent::div"/>
<!-- Select all nodes that contains @title attribute -->
<xsl:value-of select="//*[@title]"/>

Advanced used of XSLT: http://www2.informatik.hu-berlin.de/~obecker/XSLT/

Declarations in XML

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="file:///C:/path/example.xsl"?> <!-- XSL -->
<!-- XSD file is added on the root tag -->
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"