Re: [xml-bindings]CDATA nodes have no name?

On Sat, Dec 06, 2003 at 03:56:14PM -0500, Marc-Antoine Parent wrote:
> But I am interested in another issue, now:
> In
> def nodeWrap(o):
>     # TODO try to cast to the most appropriate node class
>     name =
>     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?

  Hum, the data type should be checked first,

> 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!

  The type should really be used to make the differentiation, not
the returned name. For example it's perfectly legal to name element nodes
"text" like in <text/> ...

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

  The fix should be to do the test in a different way.


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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