GNOME Bugzilla – Bug 301600
xmllint reports failure to load (external) dtds when --nonet specified
Last modified: 2015-07-06 12:36:49 UTC
jumbo:~/web/dc$ cat test.xml <!DOCTYPE html PUBLIC "foo" "http://www.foo.example/"> <root/> jumbo:~/web/dc$ cat minimal.dtd <!ELEMENT root EMPTY> jumbo:~/web/dc$ xmllint --nonet --dtdvalid minimal.dtd test.xml I/O error : Attempt to load network entity http://www.foo.example/ test.xml:1: warning: failed to load external entity "http://www.foo.example/" <!DOCTYPE html PUBLIC "foo" "http://www.foo.example/"> ^ <?xml version="1.0"?> <!DOCTYPE html PUBLIC "foo" "http://www.foo.example/"> <root/> (What I actually want to do is validate XHTML files using a local copy of the DTDs and entities; I'd assumed that --nonet (to not fetch DTDs) and --dtdvalid (to validate against a local DTD) would accomplish this.)
I suggest to close this 10-year old bug.
Well, for what it's worth, the behavior is exactly the same as 10 years ago. Doesn't look like this is a problem for many people though…
Hi, I've just come across this problem and was about to file a bug when I found this report. xsltproc is used by asciidoc when it builds its man pages, and I am building asciidoc in a chroot with no network access, so right now my only option to build asciidoc in this environment would seem to be to disable man page generation, which is a shame. I'm just mentioning this here to provide a real-life case where a functioning --nonet would be of use, thanks. :)
But we use it all the time, for example libvirt does that, we validate all the generated XHTML1 pages with --nonet and the XHTML1 DTD is registered in the catalog, works like a charm. The example of #1 is broken because there is nowhere where the association between <!DOCTYPE html PUBLIC "foo" "http://www.foo.example/"> and his local minimal.dtd is ever made. The document does not reference minimal.dtd, broken test. So yes in comment to #2 there is no where in the document to associate the DTD given with the document in example, that can't work ... unless you have a local catalog. W.r.t. #3 you seems to not have your catalog properly setup. Install the xhtml1-dtds in the RHEL/Fedora/CentOs familly of systems, or equivalent where you use libxml2. This populates /etc/xml/catalog used for DTD lookups without net access: thinkpad:~/XML -> grep xhtml /etc/xml/catalog <nextCatalog catalog="xhtml1-dtds-1.0-20020801.11.xml"/> thinkpad:~/XML -> cat /etc/xml/xhtml1-dtds-1.0-20020801.11.xml <?xml version="1.0"?> <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> <delegatePublic publicIdStartString="-//W3C//DTD XHTML 1.0" catalog="file:///usr/share/xml/xhtml/1.0/catalog.xml"/> <delegatePublic publicIdStartString="-//W3C//ENTITIES Latin 1 for XHTML" catalog="file:///usr/share/xml/xhtml/1.0/catalog.xml"/> <delegatePublic publicIdStartString="-//W3C//ENTITIES Special for XHTML" catalog="file:///usr/share/xml/xhtml/1.0/catalog.xml"/> <delegatePublic publicIdStartString="-//W3C//ENTITIES Symbols for XHTML" catalog="file:///usr/share/xml/xhtml/1.0/catalog.xml"/> <delegateSystem systemIdStartString="http://www.w3.org/TR/xhtml1/DTD/" catalog="file:///usr/share/xml/xhtml/1.0/catalog.xml"/> <delegateURI uriStartString="http://www.w3.org/TR/xhtml1/DTD/" catalog="file:///usr/share/xml/xhtml/1.0/catalog.xml"/> <delegateSystem systemIdStartString="http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/" catalog="file:///usr/share/xml/xhtml/1.0/catalog.xml"/> <delegateURI uriStartString="http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/" catalog="file:///usr/share/xml/xhtml/1.0/catalog.xml"/> </catalog> thinkpad:~/XML -> Then any attempt to reference part of the XHTML1 DTD from that host using libxml2 will instead use the local files from the catalog and this will work with --nonet. So #3 fix your installation it does work ! http://xmlsoft.org/catalog.html Closing that bug as Invalid Daniel