[lxml-dev] XMLSchemaParseError: Document is not XML Schema

Dwyer, Kevin Kevin.Dwyer at misys.com
Thu Apr 2 18:48:22 CEST 2009


Hello, 
 
I have encountered a problem with schema object creation with lxml; the
problem relates to namespace used for the root element of the schema.
 
<snip>
>>> import lxml.etree
>>> et = lxml.etree.ElementTree(file=open('c:\\temp\\MySchema', 'r'))
>>> et
<lxml.etree._ElementTree object at 0x011B8AF8>
>>> xsd = lxml.etree.XMLSchema(et)
 
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    xsd = lxml.etree.XMLSchema(et)
  File "xmlschema.pxi", line 50, in lxml.etree.XMLSchema.__init__
(src/lxml/lxml.etree.c:120919)
XMLSchemaParseError: Document is not XML Schema
</snip>
 
Looking in subversion
(http://codespeak.net/svn/lxml/trunk/src/lxml/xmlschema.pxi), in the
XMLSchema class I see:
 
<snip>
 
            # work around for libxml2 bug if document is not XML schema
at all
            #if _LIBXML_VERSION_INT < 20624:
            c_node = root_node._c_node
            c_href = _getNs(c_node)
            if c_href is NULL or \
                   cstd.strcmp(c_href,
'http://www.w3.org/2001/XMLSchema') != 0:
                raise XMLSchemaParseError, u"Document is not XML Schema"
</snip>
The schemas that I am using use this root element:
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
If I change them to <xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> they validate.  
Can you explain why the earlier namespace definition is unacceptable?
Is there a workaround?  
The schemas are not built by my application, so changing them might be
an issue.

Cheers,

 

Kevin



"Misys" is the trade name for Misys plc (registered in England and Wales). Registration Number: 01360027. Registered office: One Kingdom Street, London W2 6BL, United Kingdom. For a list of Misys group operating companies please go to http://www.misys.com/corp/About_Us/misys_operating_companies.html. This email and any attachments have been scanned for known viruses using multiple scanners. This email message is intended for the named recipient only. It may be privileged and/or confidential. If you are not the named recipient of this email please notify us immediately and do not copy it or use it for any purpose, nor disclose its contents to any other person. This email does not constitute the commencement of legal relations between you and Misys plc. Please refer to the executed contract between you and the relevant member of the Misys group for the identity of the contracting party with which you are dealing. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/lxml-dev/attachments/20090402/1bcf0700/attachment.htm 


More information about the lxml-dev mailing list