Hello
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