[Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.19,1.20

Martin v. Löwis loewis@users.sourceforge.net
Sat, 27 Jan 2001 00:38:37 -0800


Update of /cvsroot/python/python/dist/src/Lib/xml/dom
In directory usw-pr-cvs1:/tmp/cvs-serv21482

Modified Files:
	minidom.py 
Log Message:
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.


Index: minidom.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** minidom.py	2001/01/08 04:04:34	1.19
--- minidom.py	2001/01/27 08:38:34	1.20
***************
*** 32,38 ****
  import xml.dom
  _Node = xml.dom.Node
- del xml
  
- 
  class Node(_Node):
      allnodes = {}
--- 32,36 ----
***************
*** 318,322 ****
          L = []
          for node in self._attrs.values():
!             L.append((node.tagName, node.value))
          return L
  
--- 316,320 ----
          L = []
          for node in self._attrs.values():
!             L.append((node.nodeName, node.value))
          return L
  
***************
*** 336,339 ****
--- 334,340 ----
          return self._attrs.values()
  
+     def get(self, name, value = None):
+         return self._attrs.get(name, value)
+ 
      def __len__(self):
          return self.length
***************
*** 454,458 ****
      def setAttributeNode(self, attr):
          if attr.ownerElement not in (None, self):
!             raise ValueError, "attribute node already owned"
          old = self._attrs.get(attr.name, None)
          if old:
--- 455,459 ----
      def setAttributeNode(self, attr):
          if attr.ownerElement not in (None, self):
!             raise xml.dom.InuseAttributeErr("attribute node already owned")
          old = self._attrs.get(attr.name, None)
          if old:
***************
*** 568,572 ****
      def splitText(self, offset):
          if offset < 0 or offset > len(self.data):
!             raise ValueError, "illegal offset value for splitText()"
          newText = Text(self.data[offset:])
          next = self.nextSibling
--- 569,573 ----
      def splitText(self, offset):
          if offset < 0 or offset > len(self.data):
!             raise xml.dom.IndexSizeErr("illegal offset value")
          newText = Text(self.data[offset:])
          next = self.nextSibling
***************
*** 617,621 ****
      def createDocument(self, namespaceURI, qualifiedName, doctype):
          if doctype and doctype.parentNode is not None:
!             raise ValueError, "doctype object owned by another DOM tree"
          doc = Document()
          if doctype is None:
--- 618,622 ----
      def createDocument(self, namespaceURI, qualifiedName, doctype):
          if doctype and doctype.parentNode is not None:
!             raise xml.dom.WrongDocumentErr("doctype object owned by another DOM tree")
          doc = Document()
          if doctype is None:
***************
*** 625,631 ****
              if prefix == "xml" \
                 and namespaceURI != "http://www.w3.org/XML/1998/namespace":
!                 raise ValueError, "illegal use of 'xml' prefix"
              if prefix and not namespaceURI:
!                 raise ValueError, "illegal use of prefix without namespaces"
          doctype.parentNode = doc
          doc.doctype = doctype
--- 626,632 ----
              if prefix == "xml" \
                 and namespaceURI != "http://www.w3.org/XML/1998/namespace":
!                 raise xml.dom.NamespaceErr("illegal use of 'xml' prefix")
              if prefix and not namespaceURI:
!                 raise xml.dom.NamespaceErr("illegal use of prefix without namespaces")
          doctype.parentNode = doc
          doc.doctype = doctype
***************
*** 661,665 ****
          if node.nodeType == Node.ELEMENT_NODE \
             and self._get_documentElement():
!             raise TypeError, "two document elements disallowed"
          return Node.appendChild(self, node)
  
--- 662,666 ----
          if node.nodeType == Node.ELEMENT_NODE \
             and self._get_documentElement():
!             raise xml.dom.HierarchyRequestErr("two document elements disallowed")
          return Node.appendChild(self, node)