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