summaryrefslogtreecommitdiffstats
path: root/Lib/xml/dom
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2000-10-06 22:36:03 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2000-10-06 22:36:03 (GMT)
commit2c8a89cc3f141f574982b66383c533e7ecbe4aac (patch)
treed4607b60d442682ec54433daad215a1c5c4de8c9 /Lib/xml/dom
parent80670bcabaf071bfe9131f3907b44632a672f9cb (diff)
downloadcpython-2c8a89cc3f141f574982b66383c533e7ecbe4aac.zip
cpython-2c8a89cc3f141f574982b66383c533e7ecbe4aac.tar.gz
cpython-2c8a89cc3f141f574982b66383c533e7ecbe4aac.tar.bz2
minidom: access attribute value before printing it
correct order of constructor args in createAttributeNS pulldom: use symbolic names for uri and localnames correct usage of createAttribute and setAttributeNode signatures.
Diffstat (limited to 'Lib/xml/dom')
-rw-r--r--Lib/xml/dom/minidom.py4
-rw-r--r--Lib/xml/dom/pulldom.py22
2 files changed, 14 insertions, 12 deletions
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py
index 80771ad..7d610c6 100644
--- a/Lib/xml/dom/minidom.py
+++ b/Lib/xml/dom/minidom.py
@@ -331,7 +331,7 @@ class Element( Node ):
for a_name in a_names:
writer.write(" %s=\"" % a_name)
- _write_data(writer, self._get_attributes()[a_name])
+ _write_data(writer, self._get_attributes()[a_name].value)
writer.write("\"")
if self.childNodes:
writer.write(">")
@@ -429,7 +429,7 @@ class Document(Node):
def createAttributeNS(self, namespaceURI, qualifiedName):
prefix,localName = _nssplit(qualifiedName)
- return Attr(namespaceURI, qualifiedName, localName, prefix)
+ return Attr(qualifiedName, namespaceURI, localName, prefix)
def getElementsByTagNameNS(self, namespaceURI, localName):
_getElementsByTagNameNSHelper(self, namespaceURI, localName)
diff --git a/Lib/xml/dom/pulldom.py b/Lib/xml/dom/pulldom.py
index 9f93d6a..f1e5126 100644
--- a/Lib/xml/dom/pulldom.py
+++ b/Lib/xml/dom/pulldom.py
@@ -27,26 +27,28 @@ class PullDOM(xml.sax.ContentHandler):
del self._ns_contexts[-1]
def startElementNS(self, name, tagName , attrs):
- if name[0]:
+ uri,localname = name
+ if uri:
# When using namespaces, the reader may or may not
# provide us with the original name. If not, create
# *a* valid tagName from the current context.
if tagName is None:
- tagName = self._current_context[name[0]] + ":" + name[1]
- node = self.document.createElementNS(name[0], tagName)
+ tagName = self._current_context[uri] + ":" + localname
+ node = self.document.createElementNS(uri, tagName)
else:
# When the tagname is not prefixed, it just appears as
- # name[1]
- node = self.document.createElement(name[1])
+ # localname
+ node = self.document.createElement(localname)
for aname,value in attrs.items():
- if aname[0]:
- qname = self._current_context[name[0]] + ":" + aname[1]
- attr = self.document.createAttributeNS(name[0], qname)
+ a_uri, a_localname = aname
+ if a_uri:
+ qname = self._current_context[a_uri] + ":" + a_localname
+ attr = self.document.createAttributeNS(a_uri, qname)
else:
- attr = self.document.createAttribute(name[0], name[1])
+ attr = self.document.createAttribute(a_localname)
attr.value = value
- node.setAttributeNode(qname, attr)
+ node.setAttributeNode(attr)
parent = self.curNode
node.parentNode = parent