Xs: import schemaLirect redirects not follow / https not supported in lxml?

We recently moved to https everywhere in our production infrastructure and this is causing some XML schema validation issues and I am wondering if anyone can help me clarify.

We have schema documents available via static paths on our server and they were once available at http://path.to/schema.xsd . They are no longer available there, instead of being at https://path.to/schema.xsd , but any access to the original URL results in a 301 (Moved Permanentently).

The schema documents themselves have links to each other, in particular, there is a parent schema, which includes the line:

<xs:import namespace="http://example.com/schemas/iso_639-2b/1.0" 
   schemaLocation="http://example.com/static/iso_639-2b.xsd">

      

(note that schemaLocation is still pointing to the http version of the url as we didn't expect you to need to change that, which is with a redirect in place)

When trying to validate incoming XML document against schema

schema_path = "/path/to/file/on/disk/schema.xsd"
schema_file = open(schema_path)
schema_doc = etree.parse(schema_file)
schema = etree.XMLSchema(schema_doc)

      

The .xsd root schema is loaded (since it comes from local disk), but on the last line when we initialize XMLSchema (using lxml as the base etree implementation) we get an exception:

{XMLSchemaParseError}element decl. 'language', attribute 'type': The QName value '{http://example.com/schemas/iso_639-2b/1.0}LanguageCodeType' does not resolve to a(n) type definition., line 41

      

My working theory is that lxml (or even the xml schema spec, although I couldn't find any documentation) either doesn't do redirects or doesn't support https (or both!).

Any information and advice on which appropriate fix would be appreciated.

+3


source to share





All Articles