[lxml-dev] lxml 2.2 validation question

James Slagle james.slagle at gmail.com
Tue May 19 04:21:03 CEST 2009


Hello,

I'm having some trouble getting lxml (v. 2.2) to validate an ElementTree
object that I'm building and was hoping someone on the list could help and
maybe tell me what I'm doing wrong.

If I create an ElementTree object directly from xml and an associated
schema,
it will validate fine.  If I then construct a similar ElementTree object by
just instantianting ElementTree, it will not validate.  The odd thing is
that the resulting xml from etree.tostring for both objects is identical.

I've attached a python script that shows the problem I'm having.  The
validation error is:
*** DocumentInvalid: Element 'Foo': No matching global declaration available
for the validation root.

I can get the second ElementTree object (etree2) to validate if I put the
long
explicit namesplace in front of the tag value (Foo) when I create etree2 in
the
script.  So, if I change line 25 in the script to:
rootelem = etree.Element('{http://example.com}Foo', {}, nsmap)
, it will validate.

However, the 2 resulting xml outputs are no longer equal b/c the output from

etree2 is output with explict namespaces.

Any ideas?  Thanks for any help.

-- James Slagle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/lxml-dev/attachments/20090518/38045aa8/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lxmltest.py
Type: text/x-python
Size: 912 bytes
Desc: not available
Url : http://codespeak.net/pipermail/lxml-dev/attachments/20090518/38045aa8/attachment.py 


More information about the lxml-dev mailing list