NetBeansв„ў IDE Field Guide: Developing Desktop, Web, Enterprise, and Mobile Applications (2nd Edition)

The <xsl:when> element always appears as a child of <xsl:choose> . It defines a condition to be tested and the action to be performed if the condition is true.

Changes in 2.0

None.

Format

<xsl:when test = expression> <!-- Content: sequence-constructor --> </xsl:when>

Position

<xsl:when> is always a child element of <xsl:choose> . There must be at least one <xsl:when> element within an <xsl:choose> element.

Attributes

Name

Value

Meaning

test

mandatory

Expression

The boolean condition to be tested

Content

A sequence constructor.

Effect

The <xsl:choose> element is evaluated as follows :

Any XPath expression may be evaluated to obtain an effective boolean value. In brief, the rules are:

The test expression in a <xsl:when> element after the selected one is not evaluated. This means it is safe to write code such as this:

<xsl:choose> <xsl:when test="not($x castable as xs:integer)"> <xsl:sequence select="-1"/> </xsl:when> <xsl:when test=''xs:integer($x) lt 0"> <xsl:sequence select="-1"/> </xsl:when> <xsl:otherwise> <xsl:sequence select="xs:integer($x)"/> </xsl:otherwise> </xsl:choose>

The conversion to an integer will not be attempted, and cannot therefore cause a failure, if the condition in the first <xsl:when> is true.

Usage and Examples

See <xsl:choose> on page 236

See Also

Категории