Goals of This Chapter
Branching Elements of XSLT
<xsl:if test="count(zone) > 2">
<xsl:text>Applicable zones: </xsl:text>
<xsl:apply-templates select="zone"/>
</xsl:if>
<xsl:template match="table-row">
<tr>
<xsl:attribute name="bgcolor">
<xsl:choose>
<xsl:when test="@bgcolor">
<xsl:value-of select="@bgcolor"/>
</xsl:when>
<xsl:when test="position() mod 4 = 0">
<xsl:text>black</xsl:text>
</xsl:when>
<xsl:when test="position() mod 4 = 1">
<xsl:text>green</xsl:text>
</xsl:when>
<xsl:when test="position() mod 4 = 2">
<xsl:text>red</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>blue</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="*"/>
</tr>
</xsl:template>