[XML-SIG] xml.dom.core update
Fred L. Drake
Fred L. Drake, Jr." <fdrake@acm.org
Fri, 20 Nov 1998 17:51:41 -0500 (EST)
This patch fixes the Document.createElement() interface to accept
either or both a dictionary of attribute name/value pairs or keywords
on the command line. This fixes problems with the EsisBuilder as well
as making the interface more flexible.
Document.toxml() now uses all its children to generate the XML
representation; this ensures that processing instructions and comments
will be included exactly as they are included in the tree.
Andrew, please integrate these with the CVS repo. This is just what
we talked about earlier today.
-Fred
--
Fred L. Drake, Jr. <fdrake@acm.org>
Corporation for National Research Initiatives
1895 Preston White Dr. Reston, VA 20191
Index: core.py
===================================================================
RCS file: /projects/cvsroot/xml/dom/core.py,v
retrieving revision 1.30
diff -c -c -r1.30 core.py
*** core.py 1998/11/16 03:52:02 1.30
--- core.py 1998/11/20 22:45:11
***************
*** 931,943 ****
s = '<?xml version="1.0"?>\n'
if self.documentType:
s = s + self.documentType
! if len(self._node.children):
! n = self._node.children[0]
n = NODE_CLASS[ n.type ] (n, self, self)
s = s + n.toxml()
return s
! def createElement(self, tagName, **kwdict):
"Return a new Element object."
d = _nodeData(ELEMENT_NODE)
--- 931,942 ----
s = '<?xml version="1.0"?>\n'
if self.documentType:
s = s + self.documentType
! for n in self._node.children:
n = NODE_CLASS[ n.type ] (n, self, self)
s = s + n.toxml()
return s
! def createElement(self, tagName, dict={}, **kwdict):
"Return a new Element object."
d = _nodeData(ELEMENT_NODE)
***************
*** 945,950 ****
--- 944,950 ----
d.value = None
d.attributes = {}
elem = Element(d, None, self)
+ kwdict.update(dict)
for name, value in kwdict.items():
elem.setAttribute(name, value)
return elem