mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Support non-namespace elements in *ElementNS of XMLGenerator.
This commit is contained in:
parent
1654b43ef7
commit
cf0a1cc417
2 changed files with 15 additions and 3 deletions
|
@ -62,7 +62,12 @@ class XMLGenerator(handler.ContentHandler):
|
|||
self._out.write('</%s>' % name)
|
||||
|
||||
def startElementNS(self, name, qname, attrs):
|
||||
name = self._current_context[name[0]] + ":" + name[1]
|
||||
if name[0] is None:
|
||||
# if the name was not namespace-scoped, use the unqualified part
|
||||
name = name[1]
|
||||
else:
|
||||
# else try to restore the original prefix from the namespace
|
||||
name = self._current_context[name[0]] + ":" + name[1]
|
||||
self._out.write('<' + name)
|
||||
|
||||
for pair in self._undeclared_ns_maps:
|
||||
|
@ -75,7 +80,10 @@ class XMLGenerator(handler.ContentHandler):
|
|||
self._out.write('>')
|
||||
|
||||
def endElementNS(self, name, qname):
|
||||
name = self._current_context[name[0]] + ":" + name[1]
|
||||
if name[0] is None:
|
||||
name = name[1]
|
||||
else:
|
||||
name = self._current_context[name[0]] + ":" + name[1]
|
||||
self._out.write('</%s>' % name)
|
||||
|
||||
def characters(self, content):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue