Re: Cannot <include> from a network location

The no_network argumenr to the XMLParser constructor does not seem to be working as described. The following import io from lxml import etree schema='''<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:paulhiggs:my-patch" elementFormDefault="qualified" attributeFormDefault="unqualified"> <!-- Include patch operations from RFC5261 --> <include schemaLocation="https://www.iana.org/assignments/xml-registry/schema/patch-ops.xsd"/> <element name="Patch" type="PatchType"/> <!-- Patch --> <complexType name="PatchType"> <choice minOccurs="1" maxOccurs="unbounded"> <element name="add" type="add"/> <element name="remove" type="remove"/> <element name="replace" type="replace"/> </choice> <attribute name="paulsAttrib" type="string" use="required"/> </complexType> </schema> ''' parser=etree.XMLParser(load_dtd=True, no_network=False, huge_tree=True, resolve_entities=True) s=etree.parse(io.StringIO(schema), parser) my_schema=etree.XMLSchema(s) yields an unexpected error G:\lxml-test>python 10.py Traceback (most recent call last): File "G:\lxml-test\10.py", line 28, in <module> my_schema=etree.XMLSchema(s) File "src\lxml\xmlschema.pxi", line 88, in lxml.etree.XMLSchema.__init__ lxml.etree.XMLSchemaParseError: Element '{http://www.w3.org/2001/XMLSchema}include': Failed to load the document 'https://www.iana.org/assignments/xml-registry/schema/patch-ops.xsd' for inclusion., line 3 If I curl -O https://www.iana.org/assignments/xml-registry/schema/patch-ops.xsd and change to <include schemaLocation=" patch-ops.xsd"/> the loading of the schema is successful Just a thought: Might this be proxy- or https-related? Does it work if you locally serve the xs:included schema with http? I *think* libxml2 respects http_proxy but I don't know anything about https support. Then maybe using s.th. else for the http(s) access to the resources (e.g. requests) could work; I suspect one might need to use resolvers somehow for the "indirect" xs:include dependencies (https://lxml.de/resolvers.html). Never done that myself so be just a wild guess. I could be totally wrong ;-). Regards, Holger [cid:image001_e3261df1-efb3-4c64-a4de-9b63c5e52cfb.png]<https://www.lbbw.de/> [cid:image002_15f56f09-b8fe-4ddc-a247-e3cf3d25c71f.png]<https://twitter.com/lbbw> [cid:image003_e01dca75-944e-4ea3-8463-c9c061e5b36b.png] <https://www.linkedin.com/company/lbbw> [cid:image004_5642e2b4-e190-4f0c-a274-7ceb59fe913c.png] <https://www.xing.com/company/lbbw> [cid:image005_53d53024-7202-4d60-8d95-dc0f361239ca.png] <https://www.facebook.com/LBBW.Stuttgart/> [cid:image006_9c0b6462-8935-4b9c-9fe3-0caa90d8623b.png] <https://www.youtube.com/user/LBBWDirekt> [cid:image007_9a7ebd18-8e4e-4c3e-931a-ecc4bf575ace.png] <https://www.instagram.com/lbbw_karriere/> Landesbank Baden-Wuerttemberg Anstalt des oeffentlichen Rechts Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz HRA 12704 Amtsgericht Stuttgart HRA 4356, HRA 104 440 Amtsgericht Mannheim HRA 40687 Amtsgericht Mainz Die LBBW verarbeitet gemaess Erfordernissen der DSGVO Ihre personenbezogenen Daten. Informationen finden Sie unter https://www.lbbw.de/datenschutz.
participants (1)
-
Holger.Joukl@LBBW.de