Tom --

Don't feel bad.  This is very confusing.  Even Mike Kay's book had it
wrong in the first edition.  I corrected this in XalanJ way back when.

In XSLT 11.1
(http://www.w3.org/TR/xslt.html#section-Result-Tree-Fragments), it
states:  "A result tree fragment is treated equivalently to a node-set
that contains just a single root node." This means that an RTF always
contains at least one node so it can never be empty.  That root node has
no descendants but the node-set does contain the root node.

XSLT 11.1 goes on to say "When a permitted operation is performed on a
result tree fragment, it is performed exactly as it would be on the
equivalent node-set." So, the result of boolean on an RTF is always
true!

Gary

Tom Amiro wrote:
> 
> I've puzzled over conf test boolean43 and can't figure out why
> the expected result of "true" is correct. Note the xml doc does not
> have a "foo" element. Indeed, Xalan, XT,  and Saxon return
> "true" on this test. XSLTC returns "false". We're outnumbered,
> but it looks to me like "false" is the correct answer.
> 
> Here's the xsl
> 
>   <xsl:variable name="emptyResultTreeFragTest">
>     <xsl:value-of select="foo"/>
>   </xsl:variable>
> 
>   <xsl:template match="doc">
>     <out>
>       <xsl:value-of select="boolean($emptyResultTreeFragTest)"/>
>     </out>
>   </xsl:template>
> 
> I checked the string-length of  the "emptyResultTreeFragTest"
> variable and it was 0. I also explicitly converted it to a string
> with the string function and printed it out. That showed an
> empty string.
> 
> So I don't see how applying the boolean function to the variable
> can return "true". The XSLT spec says a node-set is true only
> if it is non-empty and that a string is true if and only if its
> length is non-zero.
> 
> What am I missing?
> 
> Tom

Reply via email to