Reputation: 593
So I am trying to generate xml based on an xml boolean radio option. But as I am new to xsl in general, the variable concept at this depth is a bit out of my reach.
My XML:
<item name="commentOutNode" pathid="commentOutNode">
<radio>
<option label="Yes" value="true"/>
<option label="No" value="false" selected="t"/>
</radio>
</item>
My Current XSL:
<xsl:variable name="commentOutNode" select="commentOutNode/@value[.]"/>
***
(a ways down)
***
<xsl:when test="$commentOutNode = true">
# do this stuff
</xsl:when>
<xsl:otherwise>
# do this other stuff
</xsl:otherwise>
How can I leverage the selected radio option's value for the xsl variable and then test what it is?
Upvotes: 0
Views: 1336
Reputation: 11983
To get the value
attribute of the selected option of the item with name commentOutNode
use the XPath:
//item[@name='commentOutNode']/radio/option[@selected='t']/@value
To set a variable with such value:
<xsl:variable name="selectedValue" select="//item[@name='commentOutNode']/radio/option[@selected='t']/@value"/>
To test the variable:
<xsl:choose>
<xsl:when test="$selectedValue='true'">
. . .
</xsl:when>
<xsl:otherwise>
. . .
</xsl:otherwise>
</xsl:choose>
Upvotes: 2