Ayrad
Ayrad

Reputation: 4056

xsl checking variable doesn't seem to work

when I output the value of the node directly for example:

 <fo:inline><xsl:value-of select="isEnabled" /></fo:inline>

I get the correct string outputted in pdf "true"..

but if I set the value of isEnabled directly to a variable and then try to do the comparison on it.. it doesn't seem to work as if the node doesn't exist.

<xsl:variable name="isEnabled" select="isEnabled" />

<xsl:choose>
<xsl:when test="$isEnabled = 'true'">
   dostuff...

It seems that the value is never received correctly here and the test always fails

Any ideas?

Upvotes: 0

Views: 213

Answers (3)

Ayrad
Ayrad

Reputation: 4056

ok turned out it wasn't an xsl issue but the problem is much earlier.. at the velocity template that generates the xml for the transformation. How can I close this question?

Upvotes: 0

rsp
rsp

Reputation: 23373

How about?

<xsl:variable name="isEnabled">
    <xsl:value-of select="isEnabled" />
</xsl:variable>

<xsl:when test="normalize-space($isEnabled)='true'">

Upvotes: 1

Ron&#39;s Brain
Ron&#39;s Brain

Reputation: 271

Does isEnabled contain whitespace?

<isEnabled>true</isEnabled>

vs.

<isEnabled>true </isEnabled>

or

<isEnabled>
true
</isEnabled>

will give different results for your test. The first one should pass, the next two likely will not. Yet, they may all appear to render as the text "true" when using value-of.

Upvotes: 3

Related Questions