Re: [xml] MacOSX specific problem when using xmlXPathNodeSetIsEmpty()

xmlXPathNodeSetIsEmpty is a macro defined in include/libxml/xpath.h:

#define xmlXPathNodeSetIsEmpty(ns) \
    (((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL))

so all it is doing is comparing a few data values to zero. I cannot see what the problem might be;
there are no compiler errors when I build the code.

I notice you're using C++.  How is _query defined?

Steve Ball

On 18/06/2004, at 7:14 AM, Håkon Skjelten wrote:


I'm working on a project where we use libxml2 to store level data. The code
works perfectly on GNU/Linux (PPC/i386/AMD64) but it fails on MacOSX.

The code that fails is the xmlXPathNodeSetIsEmpty(_query->nodesetval)
function call. For some reason it returns TRUE on MacOSX even though this is not correct (same code & XML file returns FALSE in GNU/Linux). All other
libxml2 functions seems to work fine on the Mac.

The method that fails:
int XMLParser::query_start(std::string xpath)
  if (_query != NULL)
     return -1;

  _query_element = 0;
  xmlXPathContextPtr context = xmlXPathNewContext(_xmlDocument);
  _query = xmlXPathEvalExpression( (xmlChar*)xpath.c_str(), context);

  This does not work either:
     if (xmlXPathNodeSetGetLength(_query->nodesetval) == 0) {
  if (xmlXPathNodeSetIsEmpty(_query->nodesetval)) {
     _query_matches = 0;
     _query_attr = NULL;
  } else {
     _query_matches = _query->nodesetval->nodeNr;
     _query_attr =  _query->nodesetval->nodeTab[0]->properties;

  return 0;

_query_matches always equals 0 on MacOSX (and if I skip the entire test and set _query_matches = _query->nodesetval->nodeNr; I get a segmentation fault).

The same problem occur both on old and new versions of libxml2.

Is this a known problem? Are there any known workarounds? Suggestions?

Håkon Skjelten  (skjelten pvv org)
Student, Engineering Cybernetics
Norwegian University of Science and Technology
xml mailing list, project page
xml gnome org


Steve Ball            |   XSLT Standard Library   | Training & Seminars
Zveno Pty Ltd         |     Web Tcl Complete      |   XML XSL Schemas |      TclXML TclDOM        | Tcl, Web Development
Steve Ball zveno com  +---------------------------+---------------------
Ph. +61 2 6242 4099   |   Mobile (0413) 594 462   | Fax +61 2 6242 4099

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