[lxml-dev] XMLSchema validation with XMLSchema.xsd failing

Stefan Behnel stefan_ml at behnel.de
Sun Jun 3 18:13:58 CEST 2007


Hi,

David Pratt wrote:
> Can someone advise whether XMLSchema is currently able validate xml 
> schemas.

Yes, that's its purpose.


> I am on mac 10.4.9 using lxml 1.3 beta using macs default 
> libxml2.

That *might* be a problem. XML Schema support is still being worked on in
libxml2 and there may still be schemas that don't work. However, MacOS-X is
known for not shipping with up-to-date versions of libxml2, so you might have
more luck with installing a newer version.


>  >>> import lxml.etree
>  >>> from am.xmlschema import xmlschema_path
>  >>> xmlschema_doc = lxml.etree.parse(xmlschema_path)
>  >>> try:
> ...     xmlschema = lxml.etree.XMLSchema(xmlschema_doc)
> ... except Exception, e:
> ...     print e.error_log
> ...
> /Users/davidpratt/Desktop/xmlschemademo/dev/am.xmlschema/src/am/xmlschema/XMLSchema.xsd:655:ERROR:SCHEMASP:SCHEMAP_REDEFINED_ELEMENT: 
> Element 'element': A global element declaration with the name 'element' 
> does already exist.
> /Users/davidpratt/Desktop/xmlschemademo/dev/am.xmlschema/src/am/xmlschema/XMLSchema.xsd:864:ERROR:SCHEMASP:SCHEMAP_REDEFINED_ELEMENT: 
> Element 'element': A global element declaration with the name 'group' 
> does already exist.

If you are sure the document is correct (and it's usually a good idea to
verify with a second tool), a more recent version of libxml2 might help.
Otherwise, please file a bug report on libxml2's XML Schema implementation.

Stefan


More information about the lxml-dev mailing list