Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XSLT Element

XSLT xsl:choose Element


XSLT Element Reference Manual XSLT Element Reference Manual


Definition and Usage

xsl:choose element is used together with xsl:when and xsl:otherwise to express multiple conditional tests.

If no xsl:when is true, then process xsl:otherwise .

If no xsl:when is true, and there is no xsl:otherwise element, no content is created.

**Tip:** For simple conditional tests, use the xsl:if element instead.


Syntax

xsl:choose

property

None


Example

The following code adds a pink background color to the artist column when the price of a CD is higher than 10.

Example

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

My CD Collection

xsl:choose

xsl:otherwise

Title Artist

Try it »

Declare a variable named "color". Assign the value of this variable to the color attribute of the current element. If the current element has no color attribute, the value of "color" is "green":

xsl:choose

xsl:otherwisegreen


XSLT Element Reference Manual XSLT Element Reference Manual