Re: [xml] XPath Location Paths



On Fri, Apr 12, 2002 at 04:39:32PM +0100, Cyberthymia wrote:
From: "Daniel Veillard" <veillard redhat com>
  The problem is as you noted how the current node is being initialized.
XPath was not designed to be used in isolation, and does not say anything
about this. Solution: initialize the context node if you want to use
the XPath primitives directly.


Thanks.
Just had a quick look at the testXPath code to see what it does do with the
context node, and I found this:

in testXPath.c
testXPath() {
xmlXPathContextPtr ctxt;
...
  ctxt->node = xmlDocGetRootElement(document);
...
}

Shouldn't this initialise the context node to be the root node?

  Why, or why not. There is no normative document suggesting either.
Basically you should not rely on the default value, there is none,
there is one in practice but you should not rely on it when using 
libxml XPath API. The testXPath program happen to initialize it in a
given way it could be otherwise. testXPath.c could be changed, sure,
but what's the goal ?

I've just confirmed to myself that libxsl (xsltproc) does return the correct
results
if you specify the context to be "/". So the question is, how does libxsl
set the context
to the root node if it doesn't use the method testXPath does?

   By following the instructions in the XSLT specification on when and
how to change the context node (or nodeset) in the associated XPath
evaluation context.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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