Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xsl:choose check all xsl:when conditions

Tags:

xslt

xslt-2.0

Is there any way not to leave <choose> after first <when> match but continue check else conditions?

like image 856
Alexander Zhugastrov Avatar asked Dec 04 '22 16:12

Alexander Zhugastrov


1 Answers

I believe it's a no. As the spec says:

The content of the first, and only the first, xsl:when element whose test is true is instantiated. If no xsl:when is true, the content of the xsl:otherwise element is instantiated. If no xsl:when element is true, and no xsl:otherwise element is present, nothing is created.

from: http://www.w3.org/TR/xslt#section-Conditional-Processing-with-xsl:choose

you can't make it fall through other conditions like that. just convert it into a set of <xsl:if> following one another if you need a fall through

UPDATE. Here's a quote from the O'Reilly's XSLT book ( http://docstore.mik.ua/orelly/xml/xslt/ch04_02.htm ):

The C, C++, and Java switch statement is roughly equivalent to the element. The one exception is that procedural languages tend to use fallthrough processing. In other words, if a branch of the switch statement evaluates to true, the runtime executes everything until it encounters a break statement, even if some of that code is part of other branches. The element doesn't work that way. If a given evaluates to true, only the statements inside that are evaluated

like image 66
Pavel Veller Avatar answered Jan 21 '23 03:01

Pavel Veller