Samuel Bruce wrote:

Hello,

I have a xsl file which sets an xsl:variable at the start of the
file (before the match:template) from either a request parameter or
a session parameter. The variable is defined as:

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

Hello Samuel,


try to avoid Result Tree Fragments (http://www.w3.org/TR/xslt#section-Result-Tree-Fragments) by using

<xsl:variable name="var1" select="parm"/>.

Within my xsl:choose I test the value of the variable:

<xsl:choose>
<xsl:when test="$var1='A'">Display A</xsl:when>
<xsl:otherwise>Display Something Else</xsl:otherwise> </xsl:choose>

But the RTFs do not really explain this behaviour. Try


<xsl:otherwise>
  <xsl:text>$var1 = '</xsl:text>
  <xsl:value-of select="$var1"/>
  <xsl:text>'</xsl:text>
</xsl:otherwise>

So it should be obvious why the test fails.

It could also help to convert $var1 to a string explicitely:

<xsl:when test="string($var1) = 'A'">Display A</xsl:when>

Joerg

The first time through, when the variable is set to 'A' Display A
is executed. If I redirect back to this xsl later when the value of
the variable is set to 'A' Display Something Else is executed. I
have displayed the variable before the test for debugging purposes
and the variable is indeed set to 'A', but the logic doesn't seem
to follow.

Is there a way that I can see exactly what the xsl:when is
evaluating? Am I misinterpreting the behavior of xsl:when?

I am running WIN XP Professional SP1, IE 6.0, Tomcat 4.1.24-LE-jdk14, Cocoon Dev snapshot taken 6.26.2003 (2.0.5-dev)

Thank you


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to