summaryrefslogtreecommitdiff
path: root/Lib/xml/dom/pulldom.py
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2000-12-20 14:47:24 +0000
committerAndrew M. Kuchling <amk@amk.ca>2000-12-20 14:47:24 +0000
commit04a45e9bb159f348ba722d0b49f9837f91cceaea (patch)
tree0d0e69ab939dc9bfa83a378bdbfa7467525c40a1 /Lib/xml/dom/pulldom.py
parent34c20cf705045ab6e496c1271fb522cfabd409e5 (diff)
downloadcpython-git-04a45e9bb159f348ba722d0b49f9837f91cceaea.tar.gz
Patch #102492, fixing bug #116677:
give minidom.py behaviour that complies with the DOM Level 1 REC, which says that when a node newChild is added to the tree, "if the newChild is already in the tree, it is first removed." pulldom.py is patched to use the public minidom interface instead of setting .parentNode itself. Possibly this reduces pulldom's efficiency; someone else will have to pronounce on that.
Diffstat (limited to 'Lib/xml/dom/pulldom.py')
-rw-r--r--Lib/xml/dom/pulldom.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/Lib/xml/dom/pulldom.py b/Lib/xml/dom/pulldom.py
index e674385307..7f5ef79739 100644
--- a/Lib/xml/dom/pulldom.py
+++ b/Lib/xml/dom/pulldom.py
@@ -55,7 +55,9 @@ class PullDOM(xml.sax.ContentHandler):
attr.value = value
node.setAttributeNode(attr)
- node.parentNode = self.curNode
+## print self.curNode, self.curNode.childNodes, node, node.parentNode
+ self.curNode.appendChild(node)
+# node.parentNode = self.curNode
self.curNode = node
self.lastEvent[1] = [(START_ELEMENT, node), None]
@@ -77,7 +79,8 @@ class PullDOM(xml.sax.ContentHandler):
attr.value = value
node.setAttributeNode(attr)
- node.parentNode = self.curNode
+ #node.parentNode = self.curNode
+ self.curNode.appendChild(node)
self.curNode = node
self.lastEvent[1] = [(START_ELEMENT, node), None]
@@ -93,8 +96,9 @@ class PullDOM(xml.sax.ContentHandler):
def comment(self, s):
node = self.document.createComment(s)
- parent = self.curNode
- node.parentNode = parent
+ self.curNode.appendChild(node)
+# parent = self.curNode
+# node.parentNode = parent
self.lastEvent[1] = [(COMMENT, node), None]
self.lastEvent = self.lastEvent[1]
#self.events.append((COMMENT, node))
@@ -102,24 +106,27 @@ class PullDOM(xml.sax.ContentHandler):
def processingInstruction(self, target, data):
node = self.document.createProcessingInstruction(target, data)
- parent = self.curNode
- node.parentNode = parent
+ self.curNode.appendChild(node)
+# parent = self.curNode
+# node.parentNode = parent
self.lastEvent[1] = [(PROCESSING_INSTRUCTION, node), None]
self.lastEvent = self.lastEvent[1]
#self.events.append((PROCESSING_INSTRUCTION, node))
def ignorableWhitespace(self, chars):
node = self.document.createTextNode(chars)
- parent = self.curNode
- node.parentNode = parent
+ self.curNode.appendChild(node)
+# parent = self.curNode
+# node.parentNode = parent
self.lastEvent[1] = [(IGNORABLE_WHITESPACE, node), None]
self.lastEvent = self.lastEvent[1]
#self.events.append((IGNORABLE_WHITESPACE, node))
def characters(self, chars):
node = self.document.createTextNode(chars)
- parent = self.curNode
- node.parentNode = parent
+ self.curNode.appendChild(node)
+# parent = self.curNode
+# node.parentNode = parent
self.lastEvent[1] = [(CHARACTERS, node), None]
self.lastEvent = self.lastEvent[1]