This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Nekmo
Recipients Nekmo, flox, jcea
Date 2011-11-09.23:22:48
SpamBayes Score 0.0017407639
Marked as misclassified No
Message-id <1320880969.81.0.336488235094.issue13378@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2011-11-09 23:22:49Nekmosetrecipients: + Nekmo, jcea, flox
2011-11-09 23:22:49Nekmosetmessageid: <1320880969.81.0.336488235094.issue13378@psf.upfronthosting.co.za>
2011-11-09 23:22:49Nekmolinkissue13378 messages
2011-11-09 23:22:48Nekmocreate