Re: [xml] XPath Location Paths



From: "Daniel Veillard" <veillard redhat com>
On Fri, Apr 12, 2002 at 03:14:50PM +0100, Richard Jinks wrote:
If I understand the spec correctly, I'd think that as el1 is the root
node,
"name(el1)" should return "el1" and "name(el2)" should return an empty
string, i.e. it assumes that the context node is the first child of the
root
node, and not the root node itself.

I've tested this with a fresh install of libxml2.2-4-19 just to make
sure
that none of my previous dips into the XPath source code have messed
anything up.

  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?

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?

Thanks,
Richard


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




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