[XML-SIG] [ pyxml-Bugs-412141 ] pDomlette fails on cloneNode

noreply@sourceforge.net noreply@sourceforge.net
Thu, 29 Mar 2001 00:31:24 -0800


Bugs item #412141, was updated on 2001-03-29 00:31
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=106473&aid=412141&group_id=6473

Category: 4Suite
Group: None
Status: Open
Priority: 5
Submitted By: Alexandre Fayolle (afayolle)
Assigned to: Nobody/Anonymous (nobody)
Summary: pDomlette fails on cloneNode

Initial Comment:
Not all classes in pDomlette implement the cloneNode
method. PI, Attributes and Comments are notable
exceptions. However the cloneNode implementation in the
Element class calls cloneNode on all the children of
the current Element, which can result in attribute
errors.

Here's a patch against pDomlette from 4Suite 0.10.2. It
will skip children that are not elements. This
behaviour seems acceptable to me, but should be
documented somewhere if the patch was to be included in
the main distribution. 

--- /home/alf/tmp/pDomlette.py	Thu Mar 29 10:27:23 2001
+++ pDomlette.py	Thu Mar 29 10:11:50 2001
@@ -289,8 +289,9 @@
            
newElement.setAttributeNS(attr.namespaceURI,attr.name,attr.value)
         if deep:
             for c in self.childNodes:
-                nc = c.cloneNode(deep)
-                newElement.appendChild(nc)
+                if c.nodeType == c.ELEMENT_NODE:
+                    nc = c.cloneNode(deep)
+                    newElement.appendChild(nc)
             
         return newElement
     


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=106473&aid=412141&group_id=6473