Re: [xml] Bug in XPath union expressions

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Wed Jan 03 2001 - 10:23:09 EST


On Mon, Dec 18, 2000 at 03:20:19PM +0100, Martin Vidner wrote:
>
> Hi,
>
> I found the following bug: XPath union expressions are not handled
> correctly. It is apparent from the following test run:
[...]
> On the other hand, the expression '//chapter|//p' displays the correct
> result but also leaves 1 object on the stack.

  Okay I fixed both problems, thanks for the report

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

  This should actually be
           ctxt->node = xmlDocGetRootElement(document);

> if (expr)
> res = xmlXPathEvalExpression(BAD_CAST str, ctxt);
> else
> ====

  I commited this too, I'm not sure it's really useful, since
trying to handle relative expression out of context seems a bit absurd

  thanks,

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
daniel@veillard.com  | libxml Gnome XML toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Jan 03 2001 - 10:43:38 EST