Re: [xml] relative xpath matches nodes anywhere in tree

2012-06-06 Thread Daniel Veillard
On Sat, May 26, 2012 at 12:09:09PM -0400, Noam Postavsky wrote: On Sat, May 26, 2012 at 8:32 AM, Daniel Veillard veill...@redhat.com wrote: On Fri, May 25, 2012 at 06:19:49PM -0400, Noam Postavsky wrote: On Fri, May 25, 2012 at 11:38 AM, Daniel Veillard veill...@redhat.com  

Re: [xml] relative xpath matches nodes anywhere in tree

2012-06-06 Thread Liam R E Quin
On Wed, 2012-06-06 at 14:51 +0800, Daniel Veillard wrote: One of the reasons why that initialization of the context is not specified in the XPath standard is due to the fact that the standard was done with the intent to be reused (by XPointer/XLink and XSLT) and we didnt really expected

Re: [xml] relative xpath matches nodes anywhere in tree

2012-05-26 Thread Daniel Veillard
On Fri, May 25, 2012 at 06:19:49PM -0400, Noam Postavsky wrote: On Fri, May 25, 2012 at 11:38 AM, Daniel Veillard veill...@redhat.com  xmlXPathNewContext doesn't set the context node, it set it to NULL, if you keep it NULL all relative evaluations will fail (which sounds the right thing to

Re: [xml] relative xpath matches nodes anywhere in tree

2012-05-26 Thread Noam Postavsky
On Sat, May 26, 2012 at 8:32 AM, Daniel Veillard veill...@redhat.com wrote: On Fri, May 25, 2012 at 06:19:49PM -0400, Noam Postavsky wrote: On Fri, May 25, 2012 at 11:38 AM, Daniel Veillard veill...@redhat.com  xmlXPathNewContext doesn't set the context node, it set it to NULL, if you keep

Re: [xml] relative xpath matches nodes anywhere in tree

2012-05-25 Thread Daniel Veillard
On Fri, May 25, 2012 at 01:44:22AM -0400, Noam Postavsky wrote: So apparently when libxml2 evaluates an XPath expression that is relative it searches everywhere in the tree, as if the expression started with //. For instance ~/tmp$ cat test.xml ?xml version=1.0? x yTest/y /x

Re: [xml] relative xpath matches nodes anywhere in tree

2012-05-25 Thread Noam Postavsky
On Fri, May 25, 2012 at 4:44 AM, Daniel Veillard veill...@redhat.com wrote:  Actually the error is in --xpath implementation in xmllint :-) static void doXPathQuery(   ...    ctxt-node = xmlDocGetRootElement(doc);    res = xmlXPathEval(BAD_CAST query, ctxt);  here the initialization is

Re: [xml] relative xpath matches nodes anywhere in tree

2012-05-25 Thread Daniel Veillard
On Fri, May 25, 2012 at 10:44:35AM -0400, Noam Postavsky wrote: On Fri, May 25, 2012 at 4:44 AM, Daniel Veillard veill...@redhat.com wrote:  Actually the error is in --xpath implementation in xmllint :-) static void doXPathQuery(   ...    ctxt-node = xmlDocGetRootElement(doc);    res

Re: [xml] relative xpath matches nodes anywhere in tree

2012-05-25 Thread Noam Postavsky
On Fri, May 25, 2012 at 11:38 AM, Daniel Veillard veill...@redhat.com  xmlXPathNewContext doesn't set the context node, it set it to NULL, if you keep it NULL all relative evaluations will fail (which sounds the right thing to me at the XPath level) but kind of weird from an user point of

[xml] relative xpath matches nodes anywhere in tree

2012-05-24 Thread Noam Postavsky
So apparently when libxml2 evaluates an XPath expression that is relative it searches everywhere in the tree, as if the expression started with //. For instance ~/tmp$ cat test.xml ?xml version=1.0? x yTest/y /x ~/tmp$ xmllint --xpath y test.xml yTest/y My understanding of XPath says