[libxml2] Python bindings: DOM casts everything to xmlNode



commit e32ceb93f425ee852021ccda157fca923a1046b0
Author: Alexey Neyman <stilor att net>
Date:   Wed Feb 20 18:28:25 2013 -0800

    Python bindings: DOM casts everything to xmlNode
    
    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.

 python/libxml.py |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/python/libxml.py b/python/libxml.py
index c861a70..013d65c 100644
--- a/python/libxml.py
+++ b/python/libxml.py
@@ -265,22 +265,22 @@ class xmlCore:
         ret = libxml2mod.parent(self._o)
         if ret == None:
             return None
-        return xmlNode(_obj=ret)
+        return nodeWrap(ret)
     def get_children(self):
         ret = libxml2mod.children(self._o)
         if ret == None:
             return None
-        return xmlNode(_obj=ret)
+        return nodeWrap(ret)
     def get_last(self):
         ret = libxml2mod.last(self._o)
         if ret == None:
             return None
-        return xmlNode(_obj=ret)
+        return nodeWrap(ret)
     def get_next(self):
         ret = libxml2mod.next(self._o)
         if ret == None:
             return None
-        return xmlNode(_obj=ret)
+        return nodeWrap(ret)
     def get_properties(self):
         ret = libxml2mod.properties(self._o)
         if ret == None:
@@ -290,7 +290,7 @@ class xmlCore:
         ret = libxml2mod.prev(self._o)
         if ret == None:
             return None
-        return xmlNode(_obj=ret)
+        return nodeWrap(ret)
     def get_content(self):
         return libxml2mod.xmlNodeGetContent(self._o)
     getContent = get_content  # why is this duplicate naming needed ?
@@ -317,7 +317,7 @@ class xmlCore:
                 ret = libxml2mod.parent(self._o)
                 if ret == None:
                     return None
-                return xmlNode(_obj=ret)
+                return nodeWrap(ret)
             elif attr == "properties":
                 ret = libxml2mod.properties(self._o)
                 if ret == None:
@@ -327,22 +327,22 @@ class xmlCore:
                 ret = libxml2mod.children(self._o)
                 if ret == None:
                     return None
-                return xmlNode(_obj=ret)
+                return nodeWrap(ret)
             elif attr == "last":
                 ret = libxml2mod.last(self._o)
                 if ret == None:
                     return None
-                return xmlNode(_obj=ret)
+                return nodeWrap(ret)
             elif attr == "next":
                 ret = libxml2mod.next(self._o)
                 if ret == None:
                     return None
-                return xmlNode(_obj=ret)
+                return nodeWrap(ret)
             elif attr == "prev":
                 ret = libxml2mod.prev(self._o)
                 if ret == None:
                     return None
-                return xmlNode(_obj=ret)
+                return nodeWrap(ret)
             elif attr == "content":
                 return libxml2mod.xmlNodeGetContent(self._o)
             elif attr == "name":


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