[xml-bindings]CDATA nodes have no name?



Good day, all!
I built the python bindings for the (unfortunately somewhat dated) libxml2.2 library within MacOSX 10.3.1 (namely version 2.5.4, or version 8.4.0 in their terms.) I use them a lot and they work quite well for me, except for the bug I will describe.

[ As an aside, I also built libxml2 version 2.6.1, which work quite well; though regression tests get confused by utf16bom.xml file comparisons for what I suspect are endianness issues... but otherwise the C libraries mostly work; but for some reason my attempt to get the python bindings going for this library result in Segmentation faults. Did anybody have success with these? ]

But I am interested in another issue, now:
In libxml.py:
def nodeWrap(o):
    # TODO try to cast to the most appropriate node class
    name = libxml2mod.name(o)
    if name == "element" or name == "text":
....

This crashes on CDATA nodes as they have a name of None. (Or NULL from a C standpoint.) I notice that the python code did not change in 2.6.1. Do CDATA nodes still return a vacuous name? I find I am a bit confused between libxml_name and libxml_type in libxml.c, as nodeWrap seems to use the former, but take results that look as if they came from the latter.

My solution was to correct
    if name == "element" or name == "text":

but my CDATA object prints out as <xmlNode (None) object at 0x1061030>
and not <xmlNode (cdata) object at 0x1061030> as I would like... Though getting at its type or calling getContent() gives me a correct answer!

Anyway, could someone tells me if this has been fixed in latter releases, and what behaviour I should expect from them?

Marc-Antoine Parent




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