Re: [xslt] XML_DOCUMENT_NODE and boolean testing



Nick Wellnhofer wrote:
Phil Shafer wrote:
Nick Wellnhofer writes:
http://www.w3.org/TR/xslt#section-Result-Tree-Fragments
"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:

http://www.google.com/search?q=exslt+node-set+%22root+node%22

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:

http://www.cygwin.com/ml/xsl-list/2000-08/msg01106.html

"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:

http://www.w3.org/TR/xslt#section-Result-Tree-Fragments

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

Nick

See also here:

http://mail-archives.apache.org/mod_mbox/xml-xalan-dev/200009.mbox/%3C39B816AA 89166FFC firstech com%3E
http://www.google.com/search?q=xslt+%22result+tree+fragment%22+boolean

Nick


--
aevum gmbh
rumfordstr. 4
80469 münchen
germany

tel: +49 89 3838 0653
http://aevum.de/


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