Stefan Behnel <sco...@users.sourceforge.net> added the comment:

Florent, thanks for the notification.

Nekmo, note that you are misusing this feature. The _namespace_map is meant to 
provide "well known namespace prefixes" only, so that common namespaces end up 
using the "expected" prefix. This is also the reason why it maps namespaces to 
prefixes and not the other way round. It is not meant to temporarily assign 
arbitrary prefix to namespaces. That is the reason for it being a global option.

That being said, lxml.etree's Element factory takes an "nsmap" parameter that 
implements the feature you want. It's documented here:

http://lxml.de/tutorial.html#namespaces

Note that it maps prefixes to namespaces and not the other way round. This is 
because there is a corresponding "nsmap" property on Elements that provides the 
currently defined prefixes in the context of an Element. ElementTree itself 
does not (and cannot) support this property because it drops the prefixes 
during parsing. However, I would still request that an implementation of the 
parameter to the Element() factory should be compatible for both libraries.

Also look for "nsmap" in the compatibility docs (appears in two sections):

http://lxml.de/compatibility.html

----------

_______________________________________
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

Reply via email to