I need to flip the elements of two nodes. Originally the variable were set with the following command:
<xsl:variable name="matchesLeft" select="$questionObject/descendant::simpleMatchSet[position()=1]/simpleAssociableChoice"/>
<xsl:variable name="matchesRight" select="$questionObject/descendant::simpleMatchSet[position()=2]/simpleAssociableChoice"/>
I now want to flip the variable with the following code:
<xsl:variable name="matchesRight">
<xsl:choose>
<xsl:when test="$flippedQuestions='true'">
<xsl:value-of select="$questionObject/descendant::simpleMatchSet[position()=2]/simpleAssociableChoice"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$questionObject/descendant::simpleMatchSet[position()=1]/simpleAssociableChoice"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
But it only get the value from the first element and not all elements in the node. How can I achive this?
Use:
Explanation:
In XPath whenever a boolean value
$someBValis passed to a numeric operator such as+, the boolean is converted to a number (either 0 or 1) usingnumber($someBVal).By definition:
and
Thus
evaluates to 1 if the string value of
flippedQuestionsisn’t the string"true"and the same expression evaluates to 2 if the string value offlippedQuestionsis the string"true".