]> granicus.if.org Git - python/commitdiff
Merge changes up to 1.10 from PyXML:
authorMartin v. Löwis <martin@v.loewis.de>
Thu, 28 Dec 2000 18:40:56 +0000 (18:40 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Thu, 28 Dec 2000 18:40:56 +0000 (18:40 +0000)
- implement hasAttribute and hasAttributeNS (1.7)
- Node.replaceChild():  Update the sibling nodes to point to newChild.  Set
  the .nextSibling attribute on oldChild instead of adding a .newChild
  attribute (1.9).

Lib/xml/dom/minidom.py

index d078f39db3769bda554a191fbd767351ebe33d99..98a75b99f195c618e0064e1595b5e42c19980e81 100644 (file)
@@ -145,8 +145,12 @@ class Node(_Node):
             oldChild.parentNode = None
         newChild.nextSibling = oldChild.nextSibling
         newChild.previousSibling = oldChild.previousSibling
-        oldChild.newChild = None
+        oldChild.nextSibling = None
         oldChild.previousSibling = None
+        if newChild.previousSibling:
+            newChild.previousSibling.nextSibling = newChild
+        if newChild.nextSibling:
+            newChild.nextSibling.previousSibling = newChild
         return oldChild
 
     def removeChild(self, oldChild):
@@ -463,6 +467,12 @@ class Element(Node):
         del self._attrs[node.name]
         del self._attrsNS[(node.namespaceURI, node.localName)]
 
+    def hasAttribute(self, name):
+        return self._attrs.has_key(name)
+                     
+    def hasAttributeNS(self, namespaceURI, localName):
+        return self._attrsNS.has_key((namespaceURI, localName))    
+        
     def getElementsByTagName(self, name):
         return _getElementsByTagNameHelper(self, name, [])