Re: [xslt] XML_DOCUMENT_NODE and boolean testing




Is it possible that this is not a bug and the current behavior is correct? The spec says here:

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

So a RTF is always a non-empty node-set and should evaluate to true.

Nick


Phil Shafer wrote:
Daniel Veillard writes:
 maybe it's a bug, yes.

This seems to fix it:

Index: libxml2/xpath.c
===================================================================
RCS file: /cvs/junos-2001/src/contrib/libxml2/xpath.c,v
retrieving revision 1.8
diff -u -p -r1.8 xpath.c
--- libxml2/xpath.c     3 Apr 2008 21:26:20 -0000       1.8
+++ libxml2/xpath.c     11 Jul 2008 13:33:51 -0000
@@ -5940,6 +5940,16 @@ int
 xmlXPathCastNodeSetToBoolean (xmlNodeSetPtr ns) {
     if ((ns == NULL) || (ns->nodeNr == 0))
        return(0);
+    /*
+     * If the only contents of the node-set are an
+     * XML_DOCUMENT_NODE, then we have a fake document
+     * returned by a template.  If it's empty, the
+     * boolean value should be false.
+     */
+    if ((ns->nodeNr == 1)
+       && (ns->nodeTab[0]->type == XML_DOCUMENT_NODE)
+       && (ns->nodeTab[0]->children == NULL))
+       return(0);
     return(1);
 }

I'll open a bug report with this patch.

Thanks,
 Phil
_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
xslt gnome org
http://mail.gnome.org/mailman/listinfo/xslt

--
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]