..." />
The Planets
</TITLE>
<PLANETS>
<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>
<PLANET>
<NAME>
<xsl:value-of select="NAME"/>
</NAME>
<DESCRIPTION>
<xsl:choose>
<xsl:when test="NAME='Mercury'">Hottest</xsl:when>
<xsl:when test="NAME='Venus'">Hot</xsl:when>
<xsl:when test="NAME='Earth'">OK</xsl:when>
</xsl:choose>
</DESCRIPTION>
</PLANET>
</xsl:template>
</xsl:stylesheet>
Вот и все.
Предположим теперь, что нам нужно добавить в каждый элемент <PLANET> атрибут COLOR:
<?xml version="1.0"?>