You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Chris P. McCabe" <ch...@choicehotels.com> on 2001/02/14 19:34:16 UTC

XalanJ2: RTFs always true

I would like to revisit this change in behavior in XalanJ2, which
I think was intentional, but I would like to verify it because it is
going to cause us a lot of grief.

In the XSL at the end of this message, I would expect it to get the same
results in each xsl:choose statement (either 'yes yes' or 'no no'
output).  But instead, the test in the first xsl:choose is always true,
so the output is always 'yes yes' or 'yes no'.
In XalanJ1 I got the results I expected (or wanted anyway).

I believe the reason is in the change with empty result tree fragments
evaluating to true.  I seem to remember reading somewhere that in the
next version of XSLT, that RTFs would essentially be the same as a
nodeset, which would mean that this behavior will again change back to
the way it was before.

Am I correct in my assumptions?

-Chris

Here is the XSL:

   <xsl:variable name="stuff">
       <xsl:value-of select="first/@attr"/>
   </xsl:variable>

   <!-- Using variable to test. -->
   <xsl:choose>
      <xsl:when test="$stuff">yes</xsl:when>
      <xsl:otherwise>no</xsl:otherwise>
   </xsl:choose>

   <!-- Direct test of attribute. -->
   <xsl:choose>
      <xsl:when test="first/@attr"> yes</xsl:when>
      <xsl:otherwise> no</xsl:otherwise>
   </xsl:choose>