XML value of boolean not getting read correctly by xslt
862820Dec 2 2011 — edited Jun 5 2012Hi,
I am sure there is a simple solution to why this is not working, but I am not able to figure out the reason though.
I have an xml like - <VersionGroup inactive="false" enabled="false">
This is just a node from a much bigger xml and it will be futile to put that big one here.
I was trying read the value of the 'enabled' attribute, using <xsl:key>defined like - <xsl:key name="versionGroup" match="X/Y/Z/VersionGroup" use="@inactive"/>
and in the core XSLT, get the value of the enabled flag using - <xsl:variable name="verGpEnabled" select="key('versionGroup', 'false')/@enabled"/>
If I do the - '<xsl:value-of select="$verGpEnabled"/'> this prints the correct o/p of the value of 'enabled' attribute, based on whether it is true or false.
However when I tried using this as a condition using <xslt:when> e.g - <xsl:when test="$verGpEnabled = 'true'">, or <xsl:when test="boolean('$verGpEnabled') = true()">, or something similar using <xslt:if> also, the results is always true, even if 'enabled' attribute is valued - 'false'.
Following example will make it more clear -
If the xslt is like -
<xsl:choose>
<xsl:when test="$verGpEnabled = 'true'">
<xsl:text> TRUE </xsl:text>
</xsl:when>
<xsl:when test="$verGpEnabled = 'false'">
<xsl:text> FALSE </xsl:text>
</xsl:when>
</xsl:choose>
Here the o/p is always TRUE even if the enabled attribute is false.
Would appreciate any help on this.
Best Regards -