<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16809" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=703052116-02042009>Hello, 
</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=703052116-02042009></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=703052116-02042009>I have encountered a 
problem with schema object creation with lxml; the problem relates to namespace 
used for the root element of the schema.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=703052116-02042009></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=703052116-02042009>&lt;snip&gt;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=703052116-02042009>&gt;&gt;&gt; import 
lxml.etree<BR>&gt;&gt;&gt; et = 
lxml.etree.ElementTree(file=open('c:\\temp\\MySchema', 'r'))<BR>&gt;&gt;&gt; 
et<BR>&lt;lxml.etree._ElementTree object at 0x011B8AF8&gt;<BR>&gt;&gt;&gt; xsd = 
lxml.etree.XMLSchema(et)</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=703052116-02042009>Traceback (most 
recent call last):<BR>&nbsp; File "&lt;pyshell#4&gt;", line 1, in 
&lt;module&gt;<BR>&nbsp;&nbsp;&nbsp; xsd = lxml.etree.XMLSchema(et)<BR>&nbsp; 
File "xmlschema.pxi", line 50, in lxml.etree.XMLSchema.__init__ 
(src/lxml/lxml.etree.c:120919)<BR>XMLSchemaParseError: Document is not XML 
Schema</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=703052116-02042009>&lt;/snip&gt;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=703052116-02042009><FONT face=Arial size=2>Looking in 
subversion (<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 XMLSchema class I see:</FONT></SPAN></DIV>
<DIV><SPAN class=703052116-02042009><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=703052116-02042009><FONT face=Arial 
size=2>&lt;snip&gt;</FONT></SPAN></DIV>
<DIV><SPAN class=703052116-02042009><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=703052116-02042009><FONT face=Arial><PRE><FONT face=Arial>            # work around for libxml2 bug if document is not XML schema at all
            #if _LIBXML_VERSION_INT &lt; 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"</FONT></PRE><PRE><FONT face=Arial>&lt;/snip&gt;</FONT></PRE><PRE><FONT face=Arial size=2>The schemas that I am using use this root element:</FONT></PRE><PRE>&lt;xsd:schema xmlns:xsd="<A href="http://www.w3.org/2000/10/XMLSchema">http://www.w3.org/2000/10/XMLSchema</A>"&gt;</PRE><PRE><FONT face=Arial>If I change them to &lt;xsd:schema xmlns:xsd="<A href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A>"&gt; they validate.  </FONT></PRE><PRE></FONT><FONT face=Arial size=2>Can you explain why the earlier namespace definition is unacceptable?  Is there a workaround?  </FONT></PRE><PRE><FONT face=Arial size=2>The schemas are not built by my application, so changing them might be an issue.</FONT></SPAN></PRE></DIV>
<DIV align=left>
<P style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 12pt" align=left><SPAN 
style="FONT-SIZE: 10pt; COLOR: #482a60; FONT-FAMILY: Arial; mso-ansi-language: EN-GB; mso-no-proof: yes"><FONT 
color=#000000><SPAN class=703052116-02042009>Cheers</SPAN>,</FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 12pt" align=left><SPAN 
style="FONT-SIZE: 10pt; COLOR: #482a60; FONT-FAMILY: Arial; mso-ansi-language: EN-GB; mso-no-proof: yes"><FONT 
face=Arial size=2></FONT></SPAN>&nbsp;</P>
<P style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 12pt" align=left><SPAN 
style="FONT-SIZE: 10pt; COLOR: #482a60; FONT-FAMILY: Arial; mso-ansi-language: EN-GB; mso-no-proof: yes"><FONT 
color=#000000>Kevin</FONT></SPAN></P></DIV><br><br>
<SPAN style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: 'Arial','sans-serif'"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>
<P class=MsoNormal style="MARGIN: 5pt 0cm; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: 'Arial','sans-serif'">"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 <A href="http://www.misys.com/corp/About_Us/misys_operating_companies.html">http://www.misys.com/corp/About_Us/misys_operating_companies.html</A>. 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. </SPAN></P>
<P class=MsoNormal style="MARGIN: 5pt 0cm; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: 'Arial','sans-serif'"><o:p></o:p></SPAN>&nbsp;</P></o:p></SPAN>
</body></HTML>