From: Martin Vidner (martin@artax.karlin.mff.cuni.cz)
Date: Mon Dec 18 2000 - 09:20:19 EST
Hi,
I found the following bug: XPath union expressions are not handled
correctly. It is apparent from the following test run:
[martin@pooh gnome-xml]$ ./testXPath '//chapter|//title|//p'
xmlXPathEval: 1 object left on the stack
Object is a Node Set :
Set contains 11 nodes:
1 ELEMENT chapter
2 ELEMENT chapter
3 ELEMENT chapter
4 ELEMENT chapter
5 ELEMENT chapter
6 ELEMENT title
7 ELEMENT title
8 ELEMENT title
9 ELEMENT title
10 ELEMENT title
11 ELEMENT title
On the other hand, the expression '//chapter|//p' displays the correct
result but also leaves 1 object on the stack.
When trying to locate the error, I also found that relative expressions
cannot be tested using testXPath:
[martin@pooh gnome-xml]$ ./testXPath './/chapter|.//p'
Error xpath.c:2518: Invalid type
.//chapter|.//p
^
xmlXPathEval: evaluation failed
Object is empty (NULL)
The following simple patch provides a context node for relative
expressions: (I am not sure whether a context node should always exist)
====
--- testXPath.c~ Mon Nov 6 17:43:11 2000
+++ testXPath.c Mon Dec 18 14:48:38 2000
@@ -98,6 +98,7 @@
} else {
#endif
ctxt = xmlXPathNewContext(document);
+ ctxt->node = document->children;
if (expr)
res = xmlXPathEvalExpression(BAD_CAST str, ctxt);
else
====
Thanks for the software.
Martin Vidner
---- Message from the list xml@rpmfind.net Archived at : http://xmlsoft.org/messages/ to unsubscribe: echo "unsubscribe xml" | mail majordomo@rpmfind.net
This archive was generated by hypermail 2b29 : Mon Dec 18 2000 - 09:44:04 EST