[lxml-dev] lxml 2.2 validation question

James Slagle james.slagle at gmail.com
Tue May 19 13:17:43 CEST 2009


On Tue, May 19, 2009 at 5:06 AM, <jholg at gmx.de> wrote:
> Some comments:
>
> > nsmap={None: 'http://example.com', 'foo': 'http://example.com'}
> > rootElem = etree.Element('Foo', {}, nsmap)
>
> Note that this does not put Foo into the http://example.com NS. It creates an element Foo wit no namespace. The nsmap is rather a collection of known namespace prefixes in the context of an element.
>

Ok, that clears things up a bit and explains the validation error.  I
also see how I can use etree.cleanup_namespaces before comparing the
xml output.

I guess the thing that I find strange is that there seems to be no way
to end up with the xml I started with in my example if I instead start
by instantiating an ElementTree object first.  Either you have the
validation error, fully prefixed namespaces, or one of the namespace
declarations removed (if you were to use cleanup_namespaces).

Thanks for your help!
-- James Slagle


More information about the lxml-dev mailing list