Thanks to all who pointed out the subtleties of the difference between
getting back a result tree fragment rather than true boolean output.
So here's my next question:
Is there a way to achieve the same effect (i.e., not getting a result
tree fragment) if you want to set a variable conditionally?
For example, suppose I wanted to do something like this:
<xsl:variable name="boolean_test">
<xsl:choose>
<!-- imagine a more rigorous test, here... -->
<xsl:when test="true()">
<!-- somehow set boolean test to true() -->
</xsl:when>
<xsl:otherwise>
<!-- somehow set boolean_test to false() -->
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Currently, I'm setting the value of the variable to the test itself, but
I can foresee cases where one might want to include a more complicated
XSL structure in the body of a variable tag such that directly using a
select isn't sufficient. In such a case, will the result always be a
result tree fragment?
If this is better posted to an XSL(T) list, I can redirect it. But it's
following up on an existing thread, so I figured I'd give it a shot.
Thanks!
-tfo
On Fri, 2003-06-20 at 16:54, Thomas F. O'Connell wrote:
> I've got a question about Xalan's behavior regarding setting booleans to
> explicit functions.
>
> If I've got a stylesheet that includes the following:
>
> <xsl:variable name="boolean_test">
> <xsl:value-of select="false()" />
> </xsl:variable>
>
> And I then use it in this sort of expression:
>
> <xsl:if test="boolean_test">
> <message>This is not what I was expecting</message>
> </xsl:if>
>
> I'll get the message every time. Is that correct and expected behavior,
> or is it a bug?
>
> -tfo