diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2001-01-27 08:38:34 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2001-01-27 08:38:34 (GMT) |
commit | d5fb58f1e34d85533dd7075541843cb6acf0f3cf (patch) | |
tree | 694f0ce95bfb7538f296fb5ffcf3bbe79e8fedc5 | |
parent | e3fc7226280c1953218afe014983a410236bc2ea (diff) | |
download | cpython-d5fb58f1e34d85533dd7075541843cb6acf0f3cf.zip cpython-d5fb58f1e34d85533dd7075541843cb6acf0f3cf.tar.gz cpython-d5fb58f1e34d85533dd7075541843cb6acf0f3cf.tar.bz2 |
Merge changes of PyXML 1.13:
Use nodeName, not tagName in attributes.
Provide get method for dictionary-like objects.
Use DOM exceptions instead of standard exceptions.
-rw-r--r-- | Lib/xml/dom/minidom.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 65af4c7..54cdea4 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -31,8 +31,6 @@ del types import xml.dom _Node = xml.dom.Node -del xml - class Node(_Node): allnodes = {} @@ -317,7 +315,7 @@ class NamedNodeMap: 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 @@ class NamedNodeMap: 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 @@ class Element(Node): 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 @@ class Text(Node): 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 @@ class DOMImplementation: 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 @@ class DOMImplementation: 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 @@ class Document(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): |