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



On Mon, Jun 28, 2004 at 06:57:21AM +1000, Steve Ball wrote:
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.

Yes - I believe the problem is bigger than just that single function/macro. 
Notice that when I change the line:
if (xmlXPathNodeSetIsEmpty(_query->nodesetval))
to
if (xmlXPathNodeSetGetLength(_query->nodesetval) == 0)
I get the same result, and if I skip the entire test the program segfaults
instantly.


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

In xml_parser.h:
 xmlXPathObjectPtr _query;

Full source code can be seen here:
http://cvs.sourceforge.net/viewcvs.py/nidhogg/nidhogg/src/


Regards,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Håkon Skjelten  (skjelten pvv org)
Student, Engineering Cybernetics
Norwegian University of Science and Technology



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

Hi

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);
 xmlXPathFreeContext(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?


Regards,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Håkon Skjelten  (skjelten pvv org)
Student, Engineering Cybernetics
Norwegian University of Science and Technology
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml



---

Steve Ball            |   XSLT Standard Library   | Training & Seminars
Zveno Pty Ltd         |     Web Tcl Complete      |   XML XSL Schemas
http://www.zveno.com/ |      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]