ogckml22.xsd imports two other schema documents (atom-author-link.xsd and xAL.xsd):
<!-- import atom:author and atom:link -->
<import namespace="http://www.w3.org/2005/Atom"
schemaLocation="atom-author-link.xsd"/>
<!-- import xAL:Address -->
<import namespace="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"
schemaLocation="http://docs.oasis-open.org/election/external/xAL.xsd"/>
If you want to parse the schema offline, you need to have both these documents available locally and he paths given by schemaLocation
must be correct.
The parsing and loading of the schema can be simplified (there is no need for StringIO
):
from lxml import etree
xmlschema_doc = etree.parse("ogckml22.xsd")
xmlschema = etree.XMLSchema(xmlschema_doc)
print xmlschema
Output:
<lxml.etree.XMLSchema object at 0x00D25120>
I don't understand what you mean by "For the record, http://www.opengis.net/kml/2.2 is not valid".
If you have internet access, you can use the URL as argument to etree.parse()
:
xmlschema_doc = etree.parse("http://www.opengis.net/kml/2.2")
At least this works for me.