Name
<xsl:choose>
Synopsis
<xsl:choose> ... </xsl:choose>
The xsl:choose
element,
in conjunction with the elements xsl:when
and xsl:otherwise
, offers the ability
to perform multiple condition tests. For example:
<xsl:template match="chapter/title"> <xsl:choose> <xsl:when test="[position()=1]"> 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, formatting depends on whether the element
is first. The string Start Here:
is applied before the first title
element,
and the string Then Read:
is placed before
the others.
Get XML Pocket Reference, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.