Support default_namespace parameter in write method?

Hiya, since Python 2.7 the xml.etree's ElementTree has supported a default namespace when serialising XML: write(file, encoding="us-ascii", xml_declaration=None, default_namespace=None, method="xml") Would it be possible to support the signature in lxml? This would make coding for both libraries easier where a default namespace is desired, as in certain parts of openpyxl, due to overly fussy or downright buggy clients? Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226

Charlie Clark schrieb am 04.12.2014 um 08:25:
since Python 2.7 the xml.etree's ElementTree has supported a default namespace when serialising XML:
write(file, encoding="us-ascii", xml_declaration=None, default_namespace=None, method="xml")
Would it be possible to support the signature in lxml? This would make coding for both libraries easier where a default namespace is desired, as in certain parts of openpyxl, due to overly fussy or downright buggy clients?
Not sure. It's due to an inherent difference in the tree models of libxml2 and ElementTree: the latter does not know about prefixes at all and handles them only in the serialiser, whereas libxml2 takes them from the in-memory tree. There is no override in libxml2's serialiser, so it would require modifying the tree's namespaces during serialisation (i.e. modification during a supposed read-only operation). I guess it's worth trying out, though. Stefan
participants (2)
-
Charlie Clark
-
Stefan Behnel