Re: add Namespace Defaulting to ElementTree.write()

Stefan Behnel <[email protected]>
Newsgroups gmane.comp.python.xml
Message-ID <[email protected]>
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
_______________________________________________
XML-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/xml-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.