diff options
author | Guido van Rossum <guido@python.org> | 2001-02-05 18:50:15 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-02-05 18:50:15 (GMT) |
commit | 795ad56b319daa610766327b99a74e5ba1ae41b2 (patch) | |
tree | dcd730f80f8ba2052e06f8fa84a0577b45d67ff6 /Lib/xml/dom/pulldom.py | |
parent | 1b26b6a5f16636c58296b852d7adaa10a44640f7 (diff) | |
download | cpython-795ad56b319daa610766327b99a74e5ba1ae41b2.zip cpython-795ad56b319daa610766327b99a74e5ba1ae41b2.tar.gz cpython-795ad56b319daa610766327b99a74e5ba1ae41b2.tar.bz2 |
Don't get fooled by an empty prefix with a valid namespaceURI -- in
this case, the code used to generate invalid tags and attribute names
with a leading colon, e.g. <:tag> or <tag :attr="foo">.
Diffstat (limited to 'Lib/xml/dom/pulldom.py')
-rw-r--r-- | Lib/xml/dom/pulldom.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/xml/dom/pulldom.py b/Lib/xml/dom/pulldom.py index 66794f3..c400742 100644 --- a/Lib/xml/dom/pulldom.py +++ b/Lib/xml/dom/pulldom.py @@ -56,7 +56,11 @@ class PullDOM(xml.sax.ContentHandler): # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: - tagName = self._current_context[uri] + ":" + localname + prefix = self._current_context[uri] + if prefix: + tagName = prefix + ":" + localname + else: + tagName = localname node = self.document.createElementNS(uri, tagName) else: # When the tagname is not prefixed, it just appears as @@ -66,7 +70,11 @@ class PullDOM(xml.sax.ContentHandler): for aname,value in attrs.items(): a_uri, a_localname = aname if a_uri: - qname = self._current_context[a_uri] + ":" + a_localname + prefix = self._current_context[a_uri] + if prefix: + qname = prefix + ":" + a_localname + else: + qname = a_localname attr = self.document.createAttributeNS(a_uri, qname) else: attr = self.document.createAttribute(a_localname) |