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

XSLT Element

XSLT xsl:when Element


XSLT Element Reference Manual Complete XSLT Element Reference Manual


Definition and Usage

xsl:when The element is used to specify actions for the xsl:choose element. xsl:when The element evaluates an expression, and if it returns true, the specified action is performed.

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


Syntax

test="boolean-expression">

property

property Value Description
test boolean-expression Required. Specifies the Boolean expression to test.

Example 1

The code below adds a pink background color to the artist column when the price of a cd is greater than 10.

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

My CD Collection

xsl:choose

xsl:otherwise

Title Artist

View the XML file、 View the XSL file、 View the result。

Example 2

Declares a variable named "color". Its value is assigned to the color attribute of the current element. If the current element has no color attribute, the value of "color" will be "green":

xsl:choose

xsl:otherwisegreen


XSLT Element Reference Manual Complete XSLT Element Reference Manual