Re: [xslt] XML_DOCUMENT_NODE and boolean testing
- From: Nick Wellnhofer <wellnhofer aevum de>
- To: The Gnome XSLT library mailing-list <xslt gnome org>
- Subject: Re: [xslt] XML_DOCUMENT_NODE and boolean testing
- Date: Fri, 11 Jul 2008 17:27:53 +0200
Nick Wellnhofer wrote:
Phil Shafer wrote:
Nick Wellnhofer writes:
"A result tree fragment is treated equivalently to a node-set that
contains just a single root node."
This root node persists even after using ext:node-set(). Is
that correct behavior?
So a RTF is always a non-empty node-set and should evaluate to true.
So my script should be saying 'test=$f/*' or 'count($f/*) > 0'?
No, I can't inspect an RTF, so I'd have to convert it to a
node-set first and then test it.
The node-set returned by exsl:node-set() always has that root node, so
the test should be 'exsl:node-set($f)/*'. See here:
It is certainly more convenient to test the variable directly,
but if that's not what the spec says, I'll close the bug and
use the above tests instead.
You might try some other XSLT processors and see what they do. It seems
that the "XSLT Programmer's Reference" says on this topic:
"The result tree fragment is first converted to a string, and the string
is then converted to a Boolean. The resulting boolean is true if the
result tree fragment contains any non-empty text nodes, and is false
But I think that contradicts the spec and libxslt is correct. The spec
"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 it shouldn't be converted to a string first.
See also here:
http://mail-archives.apache.org/mod_mbox/xml-xalan-dev/200009.mbox/%3C39B816AA 89166FFC firstech com%3E
tel: +49 89 3838 0653
] [Thread Prev