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 scoder
Recipients Nekmo, flox, jcea, scoder
Date 2011-11-11.07:06:16
SpamBayes Score 5.34991e-10
Marked as misclassified No
Message-id <1320995178.85.0.947424354839.issue13378@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2011-11-11 07:06:19scodersetrecipients: + scoder, jcea, flox, Nekmo
2011-11-11 07:06:18scodersetmessageid: <1320995178.85.0.947424354839.issue13378@psf.upfronthosting.co.za>
2011-11-11 07:06:18scoderlinkissue13378 messages
2011-11-11 07:06:16scodercreate