I am comparing two variable in xsl. When I do
<p>Language:<xsl:value-of select="$LANGUAGE_EN"/>=<xsl:value-of select="$CONTEXT_LANGUAGE"/></p>
It Output en=en
But when I compare Using:
<xsl:choose>
<xsl:when test='string($CONTEXT_LANGUAGE) = string($LANGUAGE_EN)'>
<p>English Language</p>
</xsl:when>
<xsl:otherwise>
<p>French Language</p>
</xsl:otherwise>
</xsl:choose>
It always returns French Language, but it should return English Language.
Can someone please help me on this, I lost my whole day on this?
It is likely that your values have leading and/or trailing whitespace that you are not seeing; especially if viewing the rendered HTML in a browser. In your first example, append a character before and after the values:
You could also test the
string-length()If the difference is leading or trailing whitespace, you can use the
normalize-space()function to get rid of them when comparing values: