[lxml-dev] lxml 2.2 validation question
James Slagle
james.slagle at gmail.com
Tue May 19 20:18:22 CEST 2009
On Tue, May 19, 2009 at 1:44 PM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> With "explicit", do you mean that it uses namespace prefixes instead of the
> default namespace?
Yes, exactly. So in my example, it is output as <foo:Foo>, instead of
just <Foo>.
> lxml.etree internally does some namespace cleanup on the fly and (re-)maps
> the namespaces of qualified tag names ("{abc}tag") to namespace prefixes
> depending on the place you insert an Element into a tree. Doing so, it will
> only use one namespace declaration for each mapping, even if you redeclare
> a namespace with more than one prefix. A side effect is that a namespace
> declaration may end up being unused if lxml finds a different declaration
> first.
>
> Anyway, a few things to note here:
>
> 1) namespace prefixes are highly overrated
> 2) the default namespace is highly overused, especially when mixed with
> other (prefixed) namespaces
> 3) it is rarely (not 'never', but 'rarely') useful to declare the same
> namespace more than once.
My main issue is with an external tool I'm passing my generated xml
to. This tool expects no prefixes on the elements, but prefixes on
the attributes, and thus needs the namespace declared with a prefix
and as the default. Yes, I know this is broken, and the tool needs to
be fixed to be more flexible :).
I was mainly wanting to know if it was possible to use lxml to
generate xml output in this manner.
Thanks.
-- James Slagle
More information about the lxml-dev
mailing list