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="" targetNamespace="urn:paulhiggs:my-patch" elementFormDefault="qualified" attributeFormDefault="unqualified">

    <!-- Include patch operations from RFC5261 -->

    <include schemaLocation=""/>

    <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"/>


        <attribute name="paulsAttrib" type="string" use="required"/>





parser=etree.XMLParser(load_dtd=True, no_network=False, huge_tree=True, resolve_entities=True)

s=etree.parse(io.StringIO(schema), parser)



yields an unexpected error



Traceback (most recent call last):

  File "G:\lxml-test\", line 28, in <module>


  File "src\lxml\xmlschema.pxi", line 88, in lxml.etree.XMLSchema.__init__

lxml.etree.XMLSchemaParseError: Element '{}include': Failed to load the document '' for inclusion., line 3



If I curl -O 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 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 (


Never done that myself so be just a wild guess. I could be totally wrong ;-).


Regards, Holger


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