Home > Software design >  XSLT always go to else condition
XSLT always go to else condition

Time:10-30

I have the below request as the input message.

<?xml version="1.0" encoding="UTF-8"?>
<root>
   <abcd>YES</abcd>
   <zzzzz>Test1</zzzzz>
</root>

I want to get the output like this. If, abcd equals to YES output should be R. If abcd equals to NO output should be N.

For that, I used the below condition in xslt.

<xsl:variable name="abcd" select="abcd" />
<xsl:choose>
        <xsl:when test = "$abcd=YES">R</xsl:when>
   <xsl:otherwise>N</xsl:otherwise>
</xsl:choose>

But when I execute this, I'm getting N. But the excepted value is R.

Is something missing in my XSLT block?

CodePudding user response:

Quote the string literal: $abcd='YES'.

  • Related