|
|
|
|
|
|
| |
XSLT Tutorial
XSLT Elements: xsl:choose / xsl:when /
xsl:otherwise
xsl:choose / xsl:when / xsl:otherwise
The xsl:if element was pretty restrictive in that it only allows
for one test. The xsl:choose element allows multiple choices in
a query.
<xsl:choose>
<xsl:when test=boolean expression>
template body
</xsl:when>
<xsl:otherwise>
template body
</xsl:otherwise>
</xsl:choose>
xsl:choose
- The xsl:choose element is a conditional template which defines a
choice between alternatives.
- It is similar to if-then-else statements, switch
statements or select statements found in other languages.
- There are no attributes for the xsl:choose statement.
xsl:when
- The number of xsl:when instructions is limitless.
- There must always be at least one in the body of
the xsl:choose element.
- The criteria for the test expression are the same
rules found in the xsl:if element.
- The first xsl:when statement met will be processed.
Thereafter it breaks out of the xsl:choose conditional template.
xsl:otherwise
- If none of the above xsl:when criteria are met, then
follow the xsl:otherwise instructions.
- It is optional in the body of the xsl:choose element.
- It has to be the last child of the xsl:choose
element.
Open Worksheet 6 for an xsl:choose example
|
|
|
|
|
|
|
|
|