diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-10-27 18:33:30 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-10-27 18:33:30 (GMT) |
commit | 6b03ee603315ac9e69332c8f2d064de0a98c3f15 (patch) | |
tree | 062ff0d1fa4816dd12137b65901f87a9f22c538d /Lib/xml | |
parent | c1a68363057b7b939fccbe35ab5f9d288e0ef6c1 (diff) | |
download | cpython-6b03ee603315ac9e69332c8f2d064de0a98c3f15.zip cpython-6b03ee603315ac9e69332c8f2d064de0a98c3f15.tar.gz cpython-6b03ee603315ac9e69332c8f2d064de0a98c3f15.tar.bz2 |
Issue #5027: The standard `xml` namespace is now understood by
xml.sax.saxutils.XMLGenerator as being bound to
http://www.w3.org/XML/1998/namespace. Patch by Troy J. Farrell.
Diffstat (limited to 'Lib/xml')
-rw-r--r-- | Lib/xml/sax/saxutils.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py index 46946fc..625bc12 100644 --- a/Lib/xml/sax/saxutils.py +++ b/Lib/xml/sax/saxutils.py @@ -100,6 +100,12 @@ class XMLGenerator(handler.ContentHandler): def _qname(self, name): """Builds a qualified name from a (ns_url, localname) pair""" if name[0]: + # Per http://www.w3.org/XML/1998/namespace, The 'xml' prefix is + # bound by definition to http://www.w3.org/XML/1998/namespace. It + # does not need to be declared and will not usually be found in + # self._current_context. + if 'http://www.w3.org/XML/1998/namespace' == name[0]: + return 'xml:' + name[1] # The name is in a non-empty namespace prefix = self._current_context[name[0]] if prefix: |