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



Hi libxml developers,

 

[BTW, is this list alive?]

 

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.

 

Patch attached.

 

Regards,

Alexey.

Attachment: py-wrong-node-types.diff
Description: Text Data



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