Nekmo <nin...@gmail.com> added the comment: In my case, I have several clients, and they define the namespaces. I am interested in return the same namespace that they gave me, for example, the client "A" gives me this:
<house:iq xmlns:house="http://localhost/house" /> To name the namespace, I set it at nsmap: >>> import xml.etree.ElementTree as etree >>> etree.register_namespace('house', 'http://localhost/house') >>> etree._namespace_map {'http://localhost/house': 'house', 'http://purl.org/dc/elements/1.1/': 'dc', 'http://schemas.xmlsoap.org/wsdl/': 'wsdl', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#': 'rdf', 'http://www.w3.org/1999/xhtml': 'html', 'http://www.w3.org/2001/XMLSchema': 'xs', 'http://www.w3.org/2001/XMLSchema-instance': 'xsi', 'http://www.w3.org/XML/1998/namespace': 'xml'} Thus, keeping the name of the namespace: >>> etree.tostring(etree.Element('{http://localhost/house}iq')) b'<house:iq xmlns:house="http://localhost/house" />' But if I have a client "B", which uses a different name, and run in parallel, problems can occur: <home:iq xmlns:home="http://localhost/house" /> >>> import xml.etree.ElementTree as etree >>> etree.register_namespace('home', 'http://localhost/house') >>> etree._namespace_map {'http://localhost/house': 'home', 'http://purl.org/dc/elements/1.1/': 'dc', 'http://schemas.xmlsoap.org/wsdl/': 'wsdl', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#': 'rdf', 'http://www.w3.org/1999/xhtml': 'html', 'http://www.w3.org/2001/XMLSchema': 'xs', 'http://www.w3.org/2001/XMLSchema-instance': 'xsi', 'http://www.w3.org/XML/1998/namespace': 'xml'} Therefore, I ask that _namespace_map is within etree._Element instance, and not global ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13378> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com