Dear Stephan, we (me and colleague of mine) made couple of other test: 1) we downloaded the latest version of lxml 2.3 for Windows and the behavior is exactly the same. 2) we tried to locate the problem and we have found the source of the exception is in the libxml2 and than it is passed forward to python context by the lxml wrapper 3) In this particular case the there is is a flaw in the XML Schemes since the there are two different XML Schemes for the same namespace http://www.w3.org/2001/xml.xsd http://schemas.opengis.net/gml/3.1.1/smil/xml-mod.xsd Now, if download all the XML Schemes, change the XML Schemes locations to the same URL, the problem disappears. That indicates that it is abnormal situation. At least a warning message is needed. 4) We used the xmllint for comparison (as you suggested) and we got following results for the remote schema: xmllint --noout --schema http://schemas.opengis.net/wcs/1.1/wcsGetCapabilities.xsd wcs.1.xml http://schemas.opengis.net/ows/1.1.0/ows19115subset.xsd:20: element import: Schemas parser warning : Element '{http://www.w3.org/2001/XMLSchema}import': Skipping import of schema located at 'http://www.w3.org/2001/xml.xsd' for the namespace 'http://www.w3.org/XML/1998/namespace', since this namespace was already imported with the schema located at 'http://schemas.opengis.net/gml/3.1.1/smil/xml-mod.xsd'. http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd:18: element import: Schemas parser warning : Element '{http://www.w3.org/2001/XMLSchema}import': Skipping import of schema located at 'http://www.w3.org/2001/xml.xsd' for the namespace 'http://www.w3.org/XML/1998/namespace', since this namespace was already imported with the schema located at 'http://schemas.opengis.net/gml/3.1.1/smil/xml-mod.xsd'. http://schemas.opengis.net/gml/3.1.1/base/valueObjects.xsd:215: element complexType: Schemas parser error : local list type: A type, derived by list or union, must have the simple ur-type definition as base type, not '{http://www.opengis.net/gml}doubleOrNullList'. http://schemas.opengis.net/gml/3.1.1/base/valueObjects.xsd:233: element complexType: Schemas parser error : local list type: A type, derived by list or union, must have the simple ur-type definition as base type, not '{http://www.opengis.net/gml}NameOrNullList'. WXS schema http://schemas.opengis.net/wcs/1.1/wcsGetCapabilities.xsd failed to compile and following result for the local corrected schema: xmllint --noout --schema ./schemas/ogc/wcs/1.1/wcsGetCapabilities.xsd wcs.1.xml file:///home/martin/ISS/O3S/WPS_client/schemas/ogc/gml/3.1.1/base/valueObjects.xsd:213: element complexType: Schemas parser error : local list type: A type, derived by list or union, must have the simple ur-type definition as base type, not '{http://www.opengis.net/gml}doubleOrNullList'. file:///home/martin/ISS/O3S/WPS_client/schemas/ogc/gml/3.1.1/base/valueObjects.xsd:231: element complexType: Schemas parser error : local list type: A type, derived by list or union, must have the simple ur-type definition as base type, not '{http://www.opengis.net/gml}NameOrNullList'. WXS schema ./schemas/ogc/wcs/1.1/wcsGetCapabilities.xsd failed to compile As you can see the validation ends up by an error in both cases, but the skipped imports do not seem to be the reason for the termination. Martin On 04/08/2011 09:19 AM, Stefan Behnel wrote:
Martin Paces, 07.04.2011 12:53:
I am using following python code to load an XML Schema to be used for later XML valiadtion:
#------------ import urllib from lxml import etree schema_url = "http://schemas.opengis.net/wcs/1.1/wcsGetCapabilities.xsd" schema_base = "http://schemas.opengis.net/wcs/1.1/" schema = etree.XMLSchema( etree.XML( urllib.urlopen( schema_url ).read() , base_url = schema_base ) ) #------------
The etree.XMLSchema fails with following error:
File "xmlschema.pxi", line 103, in lxml.etree.XMLSchema.__init__ (src/lxml/lxml.etree.c:116069) lxml.etree.XMLSchemaParseError: Element '{http://www.w3.org/2001/XMLSchema}import': Skipping import of schema located at 'http://www.w3.org/2001/xml.xsd' for the namespace 'http://www.w3.org/XML/1998/namespace', since this namespace was already imported with the schema located at 'http://schemas.opengis.net/gml/3.1.1/smil/xml-mod.xsd'., line 20
The issue is obvious two included independent schema documents include the same schema, but I see no reason why the XMLSchema constructor should fail by throwing an exception, N.B., when the exception says it is skipping the action. It should continue to work rather than to give it up.
So far I managed to test this issue on several Linux distributions with the same result:
Ubuntu 10.4 lxml 2.2.4 Debian Lenny lxml 2.1.1 ScinetificLin.6 lxml 2.2.3
It's at least not impossible that lxml is misinterpreting a warning as an error here. Could you try the validation with plain xmllint and see how that behaves?
Stefan