[XML-SIG] add Namespace Defaulting to ElementTree.write()
Stefan Behnel
stefan_ml at behnel.de
Mon Jul 16 08:29:20 CEST 2007
Peter Hoffmann wrote:
> As I somtimes have to look at or even edit xml markup generated by
> ElementTree, it would be a lot easier if ElementTree could use
> Namespace Defaultig as described in http://www.w3.org/TR/REC-xml-names/#defaulting
>
> Here is an example what I mean:
> ### raw input
> <book xmlns='urn:loc.gov:books'
> xmlns:isbn='urn:ISBN:0-395-36341-6'>
> <title>Cheaper by the Dozen</title>
> <isbn:number>1568491379</isbn:number>
> </book>
>
> ### normal ElementTree output
> <ns0:book xmlns:ns0="urn:loc.gov:books">
> <ns0:title>Cheaper by the Dozen</ns0:title>
> <ns1:number xmlns:ns1="urn:ISBN:0-395-36341-6">1568491379</
> ns1:number>
> </ns0:book>
>
> ### with Patch/set default_namespace="urn:loc.gov:books"
> <book xmlns="urn:loc.gov:books">
> <title>Cheaper by the Dozen</title>
> <ns1:number xmlns:ns1="urn:ISBN:0-395-36341-6">1568491379</
> ns1:number>
> </book>
lxml.etree has been using a property called "nsmap" since the beginning, which
is already more generic than just a default namespace. If ElementTree wants to
adopt such a feature, I'd be happy if it could keep up compatibility from its
own side here.
Stefan
More information about the XML-SIG
mailing list