Re: [xslt] XML_DOCUMENT_NODE and boolean testing

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 otherwise."

But I think that contradicts the spec and libxslt is correct. The spec clearly says:

"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: 89166FFC firstech com%3E


aevum gmbh
rumfordstr. 4
80469 münchen

tel: +49 89 3838 0653

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]