<xsl:choose> |
Syntax: |
<xsl:choose> <xsl:when test=”expression”> |
The xsl:choose element is used to make a choice when there are two or more possible courses of action. It provides a means for conducting multiple conditions testing. |
The xsl:choose element must contain one or more xsl:when elements and can contain only one optional xsl:otherwise element (which must occur after all of the xsl:when elements). If the xsl:chooseelement only contains one xsl:when element, then for all practical purposes, it behaves just like the xsl:if element. |
When faced with three or more choices, this element behaves like an if-then-else statement (or a Select Case) as found in numerous other computer languages. |
Each xsl:when element is examined in the order of occurrence. If and when the conditions of the test expression are satisfied (returns True), the code contained in that element is executed. |
Then the xsl:choose element is automatically exited and all further xsl:when elements are ignored and are not tested. The optional xsl:otherwise element is also automatically ignored. |
If none of the test conditions in any xsl:when element is satisfied (all return False), then the xsl:otherwise element is automatically selected (if it is present) and the code associated with that element is executed. If there is no xsl:otherwise element, then the xsl:choose element is exited. |
This element has no attributes. It is not a self-closing tag. The separate closing element is mandatory. |