Hello, <br><br><br>This is a re-post of my earlier posting, at Stefan&#39;s request, without the corporate boilerplate <br>that I inadvertently sent last time.  Sorry about that.<br><br>Bug 354574 logged at Stefan&#39;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>&lt;snip&gt;<br>&gt;&gt;&gt; import lxml.etree<br>&gt;&gt;&gt; et = lxml.etree.ElementTree(file=open(&#39;c:\\temp\\MySchema&#39;, &#39;r&#39;))<br>
&gt;&gt;&gt; et<br>&lt;lxml.etree._ElementTree object at 0x011B8AF8&gt;<br>&gt;&gt;&gt; xsd = lxml.etree.XMLSchema(et)<br> <br>Traceback (most recent call last):<br>  File &quot;&lt;pyshell#4&gt;&quot;, line 1, in &lt;module&gt;<br>
    xsd = lxml.etree.XMLSchema(et)<br>  File &quot;xmlschema.pxi&quot;, line 50, in lxml.etree.XMLSchema.__init__<br>(src/lxml/lxml.etree.c:120919)<br>XMLSchemaParseError: Document is not XML Schema<br>&lt;/snip&gt;<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>&lt;snip&gt;<br> <br>
            # work around for libxml2 bug if document is not XML schema at all<br>            #if _LIBXML_VERSION_INT &lt; 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, &#39;<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>&#39;) != 0:<br>                raise XMLSchemaParseError, u&quot;Document is not XML Schema&quot;<br>
&lt;/snip&gt;<br>The schemas that I am using use this root element:<br>&lt;xsd:schema xmlns:xsd=&quot;<a href="http://www.w3.org/2000/10/XMLSchema">http://www.w3.org/2000/10/XMLSchema</a>&quot;&gt;<br>If I change them to &lt;xsd:schema xmlns:xsd=&quot;<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>&quot;&gt; 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>