..." />
</TITLE>
<PLANETS>
The first three planets are: <xsl:apply-templates select="PLANET"/>
</PLANETS>
</DOCUMENT>
</xsl:template>
<xsl:template match="PLANET">
<xsl:if test="NAME[not(text())]">
<xsl:message terminate="yes">
Each planet must have a name!
</xsl:message>
</xsl:if>
<xsl:value-of select="NAME"/>
<xsl:if test="position()!=last()">, </xsl:if>
<xsl:if test="position()=last()-1>and </xsl:if>
<xsl:if test="position()=last()">.</xsl:if>
</xsl:template>
</xsl:stylesheet>
Теперь то же самое можно сделать при помощи единственного элемента <xsl:choose>:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xml:output method="xml"/>
<xsl:template match="PLANETS">
<DOCUMENT>
<TITLE>
The Planets
</TITLE>
<PLANETS>
The first three planets are: <xsl:apply-templates select="PLANET"/>