Re: [xml] [PATCH] Python bindings: DOM casts everything to xmlNode



On Wed, Feb 20, 2013 at 06:28:25PM -0800, Alexey Neyman wrote:
Hi libxml developers,

[BTW, is this list alive?]

  yes, why ?

I noticed another issue with Python bindings of libxml: the access methods do 
not cast the pointers to specific classes such as xmlDtd, xmlEntityDecl, etc. 
For example, with the following document:

<?xml version="1.0"?>
<!DOCTYPE root [<!ELEMENT root EMPTY>]>
<root/>

the following script:

import libxml2
doc = libxml2.readFile("c.xml", None, libxml2.XML_PARSE_DTDLOAD)
print repr(doc.children)

prints:

<xmlNode (root) object at 0xb74963ec>

With properly cast nodes, it outputs the following:

<xmlDtd (root) object at 0xb746352c>

The latter object (xmlDtd) enables one to use DTD-specific methods such as 
debugDumpDTD(), copyDTD(), and so on.

  okay, since those are subclasses of xmlNode() the
upgrade to the more specialized class should not lead to any
compatibility problem, it is a guaranteed improvement !

Patch attached.

  Applied and pushed,

   thanks !

Daniel

-- 
Daniel Veillard      | Open Source and Standards, Red Hat
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/


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