The Choose
class places all When
child-nodes
in a vector. The Choose
class translates the "test"-attribute
of all When
nodes (in strict order) and chains them together
in an if-else style. The expression that holds each test contains a true-
and a false-list. These lists are vectors of branch targets that should be
used if the test succeeds or fails, respectively. The first test's
false-list is pointed to the start of the next test (ie. if the first test
fails, then we run the next test). The last test's false-list points directly
to the code for the body of the <xsl:otherwise>
element.
Just as with the <xsl:if>
-element, special care is
taken for the element-available()
and
function-available()
functions. These functions are evaluated at
compile-time (this can be done since all parameters for these functions are
literals) and the body of a <xsl:when>
element is not
compiled if we know that it will never be needed at runtime.