June 1999
Intermediate to advanced
540 pages
21h 39m
English
<xsl:choose>
<xsl:choose>...</xsl:choose>
The <xsl:choose> element, in conjunction with the <xsl:when>
and <xsl:otherwise> elements, offers the ability to perform multiple
condition tests. For example:
<xsl:template match="chapter/title" >
<xsl:choose>
<xsl:when test=".[first-of-type()]">
Start Here:
</xsl:when>
<xsl:otherwise>
Then Read:
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</xsl:template>This example matches against each of the qualifying <title>
elements, but it must test each <title> element to determine how
to format it. Here, the formatting used depends on whether the element is
the first of its type or not. If it is, it applies the letters
“Start Here:” before the first <title> element. Otherwise, the
letters “Then Read: " are placed before the others.
Read now
Unlock full access