Attachment:
xpath.c.patch
Description: Text Data
Attachment:
tree.c.patch
Description: Text Data
Daniel, (All), 1. I've found that xpath evaluation in libxml2 behaves differently on CData section nodes if I search all text nodes with //text() or just one of them with //text()[4] (the first of these queries taking CData section into account while the second not). The attached simple patch for xpath.c fixes this. 2. I very much like the xmlGetNodePath function. I'm using Matt's and Christian's XML::LibXML Perl bindings and had this written in Perl which was a bit slow on large documents. Now, when Christian added bindings for xmlGetNodePath to XML::LibXML I can use your C implementation. It, however, only computes paths for element and attribute nodes. The attached patch against tree.c adds implementation for other types of nodes (PI, text, comments). (I only copied and slightly modifed the code that you wrote for elements and attributes). It also does a small speedup and fix on element nodes by replacing the original while (tmp != NULL) { if (xmlStrEqual(cur->name, tmp->name)) occur++; tmp = tmp->next; } if (occur != 0) occur = 1; with while (tmp != NULL && occur == 0) { // ^^^^^^^^^^^^ (a) if ((tmp->type == XML_ELEMENT_NODE) && // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (b) (xmlStrEqual(cur->name, tmp->name))) occur++; tmp = tmp->next; } if (occur != 0) occur = 1; (a) there is no need to go through all siblings if we only check that there is some (b) i guess there might be other nodes (like PI) with the same name, so we should check the node type too. I'd be glad if you could review the patches and apply them. Thanks for your great library, -- Petr Pajas XSH - XML Editing Shell (http://xsh.sourceforge.net) The ultimate command-line XML editing and browsing tool.