Re: [xml] Question regarding XPath



On Fri, Mar 16, 2007 at 09:03:01AM -0500, Ethan Metsger wrote:
happening.  xmllint does the Right Thing (i.e., it finds the fifty nodes  
we're trying to select), which is good.  I've been looking at it and the  
debugAPI code for awhile now.

By comparison, the xpath1 and xpath2 examples both return zero nodes when  
executed on the schema with the same query.  So it seems to me like  
xmllint is doing something different than the two examples provided.

  I doubt it, getting 0 nodes really seems an indication of not getting the
right binding for the namespaces. And since you don't indicate what you did
precisely nor provide the XML target I'm just left guessing and I hate that
nearly as much as debugging someone else code.
  I have seen people in the past trying to use NULL or "" to registed the
prefix of XPath queries, there is no way I can try to guess all error case
possible.

As far as I can tell, xmllint does the following:

. In response to "setns", it makes a call to xmlShellRegisterNamespace.   
This parses the provided argument into a prefix and href and registers the  
result with a call to xmlXPathRegisterNs.

. In response to "xpath", it makes a call to xmlXPathEval, passing the  
query and the document context (I think--it could also be the XPath  
context, but it's hard to tell from the code).

  yes

This isn't terribly complicated, and it looks pretty similar to what's  
happening in xpath1.c:

  make sure it's really similar, and check with a debugger that the
xmlXPathRegisterNs is called on the right context, and that the values
are correct. 

shed some light on how xmlXPathEval differs from xmlXPathEvalExpression,  
and whether the issue is related to the context passed?

  Use xmlXPathEval(), see XPath spec to see the real difference:
  http://www.w3.org/TR/xpath#NT-LocationPath
  [1]           LocationPath

  http://www.w3.org/TR/xpath#NT-Expr
  [14]          Expr

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
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]