[Bringing this back to the mailing list]
Anrik Drenth schrieb am 22.06.2018 um 01:43:
Anrik Drenth schrieb am 17.06.2018 um 04:40:
The weird thing is it loads A OK, using https, in Oxygen.
I believe that oXygen uses xerces rather than libxml2?
I think the issue is with the schema(s) having various imports. lxml might be looking locally (on the actual machine) instead of looking in the directory for the url supplied. Have just confirmed this by saving all the needed xsd files locally and then calling the main XSD vi https.
I tried changing the schemalocation i.e.:
<xsd:import namespace="http://www.w3.org/2000/09/xmldsig#"
schemaLocation="xmldsig-core-schema.xsd" />
to this:
<xsd:import namespace="http://www.w3.org/2000/09/xmldsig#"
schemaLocation="https://www.w3.org/2000/09/xmldsig" />
But this did not work.
It's always better to provide an actual error message than to state a
generic "does not work". The clearer you describe what you try and what the
result is, the more likely it is that others spot the problem.
When I change the url in the below code from http to https the following error is displayed:
lxml.etree.XMLSchemaParseError: Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'ref': The QName value '{http://www.w3.org/1999/xhtml}div' does not resolve to a(n) element declaration., line 336
I'm a bit surprised that you get a validation error here. If any of the
imported sub-schemas can't be found, you should get an error about that.
Could you check if the "schema.error_log" contains any further warnings?
OS, software, and versions
ubuntu = 16.4 LTS
python = 2.7
lxml = 4.2.1
Python Code
from lxml import etree
import urllib2
schema_src_file = urllib2.urlopen('-- url ---')
schema_doc = etree.parse(schema_src_file)
Did you also try "etree.parse('...url...')" ?
Not sure if it makes a difference, but it's simpler, at least, and the
problem here could be that libxml2 lacks information about where the schema
originally comes from, so...
schema = etree.XMLSchema(schema_doc)
What is interesting, for https, when I download and save all the supporting/imported xsd files to the local directory, the code with https works!
http works with or without the supporting xsd files.
The schemas, if needed, can be downloaded from https://files.secureserver.net/0shasWXjlDT4wT
[https://imagesak.secureserver.net/off/images2/icon_off_50_by_50.gif?v=7]<https://files.secureserver.net/0shasWXjlDT4wT>
XSDSchemas.zip<https://files.secureserver.net/0shasWXjlDT4wT>
File shared through Online Storage
files.secureserver.net
Apologies for the confusion regarding changing url references. In my many attempts to get https to work I tried many things. This included a suggestion I found on Google which said "in your main XSD if you do an import, change the schemaLocation=filename.xsd to schemaLocation=https://url/filename.xsd". I tried taht and it didnt work.
Let me know if you need anything further.
Stefan