diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 65af4c72315..54cdea4dfb2 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -31,8 +31,6 @@ import xml.dom _Node = xml.dom.Node -del xml - class Node(_Node): allnodes = {} @@ -317,7 +315,7 @@ def item(self, index): def items(self): L = [] for node in self._attrs.values(): - L.append((node.tagName, node.value)) + L.append((node.nodeName, node.value)) return L def itemsNS(self): @@ -335,6 +333,9 @@ def keysNS(self): def values(self): return self._attrs.values() + def get(self, name, value = None): + return self._attrs.get(name, value) + def __len__(self): return self.length @@ -453,7 +454,7 @@ def getAttributeNodeNS(self, namespaceURI, localName): def setAttributeNode(self, attr): if attr.ownerElement not in (None, self): - raise ValueError, "attribute node already owned" + raise xml.dom.InuseAttributeErr("attribute node already owned") old = self._attrs.get(attr.name, None) if old: old.unlink() @@ -567,7 +568,7 @@ def __repr__(self): def splitText(self, offset): if offset < 0 or offset > len(self.data): - raise ValueError, "illegal offset value for splitText()" + raise xml.dom.IndexSizeErr("illegal offset value") newText = Text(self.data[offset:]) next = self.nextSibling if self.parentNode and self in self.parentNode.childNodes: @@ -616,7 +617,7 @@ def hasFeature(self, feature, version): def createDocument(self, namespaceURI, qualifiedName, doctype): if doctype and doctype.parentNode is not None: - raise ValueError, "doctype object owned by another DOM tree" + raise xml.dom.WrongDocumentErr("doctype object owned by another DOM tree") doc = Document() if doctype is None: doctype = self.createDocumentType(qualifiedName, None, None) @@ -624,9 +625,9 @@ def createDocument(self, namespaceURI, qualifiedName, doctype): prefix, localname = _nssplit(qualifiedName) if prefix == "xml" \ and namespaceURI != "http://www.w3.org/XML/1998/namespace": - raise ValueError, "illegal use of 'xml' prefix" + raise xml.dom.NamespaceErr("illegal use of 'xml' prefix") if prefix and not namespaceURI: - raise ValueError, "illegal use of prefix without namespaces" + raise xml.dom.NamespaceErr("illegal use of prefix without namespaces") doctype.parentNode = doc doc.doctype = doctype doc.implementation = self @@ -660,7 +661,7 @@ def appendChild(self, node): if node.nodeType == Node.ELEMENT_NODE \ and self._get_documentElement(): - raise TypeError, "two document elements disallowed" + raise xml.dom.HierarchyRequestErr("two document elements disallowed") return Node.appendChild(self, node) def removeChild(self, oldChild):