Loading a local dtd-file, my script (see below) can properly check my xml-file. But If I a take a dtd-file that includes modules (.ent) my script ignores them. I checked that by removing these files which raised no error. How can I make my script consider them?
I am talking about the "-//NLM//DTD Journal Publishing DTD v2.3 20070202//EN" and the corresponding journalpublishing.dtd.
My python script:
from io import StringIO
from lxml import etree
dtd = etree.DTD("journalpublishing.dtd")
# this dtd links i.a. to "journalpubcustom-modules.ent"
xml_raw = open("fluids-01-01-00003.xml", "rb")
xml_string = xml_raw.read()
xml = etree.XML(xml_string)
if dtd.validate(xml):
print("Valid!")
else:
print(dtd.error_log.filter_from_errors())