Re: [xml] xpath and xmlXPathObject::nodesetval, need clarification

On Fri, Jun 19, 2009 at 10:07:46AM +0200, Viktor Åtujber wrote:
In the meantime, I found that the null pointer is produced in libxml's xpath.c

    contextSeq = obj->nodesetval;
    if ((contextSeq == NULL) || (contextSeq->nodeNr <= 0)) {
      xmlXPathReleaseObject(xpctxt, obj);
        valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, NULL));

Is this ok?


Why deallocate and return null, instead of keeping things

  A NULL object or an empty node set should be treated in the same way
Reason: that code may be an intermediary step in a lot of recusive
operations and it's better to not have to merge node sets than merging
an empty one, but that's from memory.

Also, I wonder... is it possible that the code I posted earlier is
handling things incorrectly? Perhaps the 'nodesetval' pointer is for
internal use only, and the application should use proper API functions
to step through the result set? If so, how?

  values inside the XPath object are public, it's part of the API. There
is no iterator API.


Daniel Veillard      | libxml Gnome XML XSLT toolkit
daniel veillard com  | Rpmfind RPM search engine | virtualization library

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