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



On Sat, May 26, 2012 at 12:09:09PM -0400, Noam Postavsky wrote:
On Sat, May 26, 2012 at 8:32 AM, Daniel Veillard <veillard 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 <veillard 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 view, so initializing to the document node sounds the best
to me.

Sure, but is there a way for a user to discover this, beside asking on
the mailing list?

 Hum, no it's really specific to xmllint, this could be added to the
man page :-)

Isn't this important info to anyone who uses one of the XPath
evaluation functions?

  The libxml2 evaluation functions really are following the XPath
specification, the spec really is the defining documentation. The
documentation of an Xpath Context in libxml2
  http://xmlsoft.org/html/libxml-xpath.html#xmlXPathContext
should show the documentation frm the code:

/**
 * xmlXPathContext:
 *
 * Expression evaluation occurs with respect to a context.
 * he context consists of:
 *    - a node (the context node) 
 *    - a node list (the context node list) 
 *    - a set of variable bindings 
 *    - a function library 
 *    - the set of namespace declarations in scope for the expression 
 * Following the switch to hash tables, this need to be trimmed up at
 * the next binary incompatible release.
 * The node may be modified when the context is passed to libxml2
 * for an XPath evaluation so you may need to initialize it again
 * before the next call.
 */

  I don't know why it wasn't extracted, I guess I need to debug this too!
Also the XPath initialization for xmllint should be documented too,
that's right.

  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 it to be used as is...

Daniel
-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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