Message147419
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 |
|
Date |
User |
Action |
Args |
2011-11-11 07:06:19 | scoder | set | recipients:
+ scoder, jcea, flox, Nekmo |
2011-11-11 07:06:18 | scoder | set | messageid: <1320995178.85.0.947424354839.issue13378@psf.upfronthosting.co.za> |
2011-11-11 07:06:18 | scoder | link | issue13378 messages |
2011-11-11 07:06:16 | scoder | create | |
|