simshadows

XML and XSLT Cheatsheet

Resources

References:

XPaths

(TODO)

XPath Axes

(TODO)

XSLT Elements

<xsl:variable name="TODO" select="TODO"/>
<xsl:variable name="TODO">
    <!-- TEMPLATE -->
</xsl:variable>

<xsl:text>TODO</xsl:text>
<xsl:value-of select="TODO"/>
<xsl:if test="TODO">
    <!-- TEMPLATE -->
</xsl:for-each>

<xsl:choose>
    <xsl:when test="TODO">
        <!-- TEMPLATE -->
    </xsl:when>
    <xsl:otherwise>
        <!-- TEMPLATE -->
    </xsl:otherwise>
</xsl:choose>

<xsl:for-each select="TODO">
    <!-- TEMPLATE -->
</xsl:for-each>
<xsl:copy-of select="TODO"/>
<xsl:copy>
    <!-- TEMPLATE -->
</xsl:copy>

<xsl:element name="TODO" namespace="TODO">
    <!-- TEMPLATE -->
</xsl:element>

<xsl:attribute name="TODO" namespace="TODO">
    <!-- TEMPLATE -->
</xsl:attribute>

XSLT Templates

<xsl:call-template name="TODO">
    <xsl:with-param name="TODO" select="TODO"/>
    <xsl:with-param name="TODO">
        <!-- TEMPLATE -->
    </xsl:with-param>
</xsl:call-template>

<xsl:apply-templates select="TODO" mode="TODO"/>
<xsl:template match="TODO" mode="TODO">
    <!-- TEMPLATE -->
</xsl:template>

<xsl:template name="TODO" mode="TODO">
    <xsl:param name="TODO" select="TODO"/>
    <!-- TEMPLATE -->
</xsl:template>
<!-- The `xsl:param` takes on `xsl:param/@select` as the default value. -->

(TODO: Can xsl:param also have child content?)

XSLT Basic Boilerplate

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />

<!-- Add your imports here -->
<xsl:import href="TODO.xsl"/>
<xsl:include href="TODO.xsl"/>
 
<xsl:template match="node()|@*">
    <xsl:copy>
        <xsl:apply-templates select="node()|@*" />
    </xsl:copy>
</xsl:template>
 
<xsl:template match="/">
    <!-- TEMPLATE -->
</xsl:template>
 
</xsl:stylesheet>