Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit aa90cb0

Browse files
committed
parser: Make failure to load main document a warning
Revert the change that made failures to load the main document an error. This fixes the --path option of xmllint and xsltproc. Should fix #733.
1 parent 9ecabe1 commit aa90cb0

12 files changed

Lines changed: 35 additions & 35 deletions

parserInternals.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ xmlCtxtErrIO(xmlParserCtxtPtr ctxt, int code, const char *uri)
180180
return;
181181

182182
/*
183-
* Don't report a well-formedness error if an external entity could
184-
* not be found. We assume that inputNr is zero for the document
185-
* entity which is somewhat fragile.
183+
* Only report a warning if a file could not be found. This should
184+
* only be done for external entities, but the external entity loader
185+
* of xsltproc can try multiple paths and assumes that ENOENT doesn't
186+
* raise an error and aborts parsing.
186187
*/
187-
if ((ctxt->inputNr > 0) &&
188-
((code == XML_IO_ENOENT) ||
188+
if (((code == XML_IO_ENOENT) ||
189189
(code == XML_IO_NETWORK_ATTEMPT) ||
190190
(code == XML_IO_UNKNOWN))) {
191191
if (ctxt->validate == 0)

python/tests/error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Memory debug specific
1111
libxml2.debugMemory(1)
1212

13-
expect='--> I/O --> error : --> failed to load "missing.xml": No such file or directory\n'
13+
expect='--> I/O --> warning : --> failed to load "missing.xml": No such file or directory\n'
1414
err=""
1515
def callback(ctx, str):
1616
global err

python/tests/input_callback.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def my_ctx_error_cb(arg, msg, severity, reserved):
9090
docpath=startURL, catalog=None,
9191
exp_status="not loaded", exp_err=[
9292
(-1, "I/O "),
93-
(-1, "error : "),
93+
(-1, "warning : "),
9494
(-1, "failed to load \"py://strings/xml/sample.xml\": No such file or directory\n")
9595
])
9696

@@ -122,7 +122,7 @@ def my_ctx_error_cb(arg, msg, severity, reserved):
122122
docpath=startURL, catalog=catURL,
123123
exp_status="not loaded", exp_err=[
124124
(-1, "I/O "),
125-
(-1, "error : "),
125+
(-1, "warning : "),
126126
(-1, "failed to load \"py://strings/xml/sample.xml\": No such file or directory\n")
127127
])
128128

@@ -142,7 +142,7 @@ def my_ctx_error_cb(arg, msg, severity, reserved):
142142
docpath="tst.xml", catalog=None,
143143
exp_status="not loaded", exp_err=[
144144
(-1, "I/O "),
145-
(-1, "error : "),
145+
(-1, "warning : "),
146146
(-1, "failed to load \"tst.xml\": No such file or directory\n")
147147
])
148148

python/tests/tstLastError.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test1(self):
6060
domain=libxml2.XML_FROM_IO,
6161
code=libxml2.XML_IO_ENOENT,
6262
message='failed to load "dummy.xml": No such file or directory\n',
63-
level=libxml2.XML_ERR_FATAL,
63+
level=libxml2.XML_ERR_WARNING,
6464
file=None,
6565
line=0)
6666

result/XInclude/fallback.xml.err

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
I/O error : failed to load "test/XInclude/docs/something.xml": No such file or directory
1+
I/O warning : failed to load "test/XInclude/docs/something.xml": No such file or directory

result/XInclude/fallback2.xml.err

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
I/O error : failed to load "test/XInclude/docs/b.xml": No such file or directory
2-
I/O error : failed to load "test/XInclude/docs/c.xml": No such file or directory
1+
I/O warning : failed to load "test/XInclude/docs/b.xml": No such file or directory
2+
I/O warning : failed to load "test/XInclude/docs/c.xml": No such file or directory

result/XInclude/fallback4.xml.err

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
I/O error : failed to load "test/XInclude/docs/c.xml": No such file or directory
1+
I/O warning : failed to load "test/XInclude/docs/c.xml": No such file or directory

result/XInclude/fallback5.xml.err

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
I/O error : failed to load "test/XInclude/docs/a01.xml": No such file or directory
2-
I/O error : failed to load "test/XInclude/docs/a02.xml": No such file or directory
3-
I/O error : failed to load "test/XInclude/docs/a03.xml": No such file or directory
4-
I/O error : failed to load "test/XInclude/docs/a04.xml": No such file or directory
5-
I/O error : failed to load "test/XInclude/docs/a05.xml": No such file or directory
6-
I/O error : failed to load "test/XInclude/docs/a06.xml": No such file or directory
7-
I/O error : failed to load "test/XInclude/docs/a07.xml": No such file or directory
8-
I/O error : failed to load "test/XInclude/docs/a08.xml": No such file or directory
9-
I/O error : failed to load "test/XInclude/docs/a09.xml": No such file or directory
10-
I/O error : failed to load "test/XInclude/docs/a10.xml": No such file or directory
11-
I/O error : failed to load "test/XInclude/docs/a11.xml": No such file or directory
12-
I/O error : failed to load "test/XInclude/docs/a12.xml": No such file or directory
13-
I/O error : failed to load "test/XInclude/docs/a13.xml": No such file or directory
14-
I/O error : failed to load "test/XInclude/docs/a14.xml": No such file or directory
15-
I/O error : failed to load "test/XInclude/docs/a15.xml": No such file or directory
16-
I/O error : failed to load "test/XInclude/docs/a16.xml": No such file or directory
1+
I/O warning : failed to load "test/XInclude/docs/a01.xml": No such file or directory
2+
I/O warning : failed to load "test/XInclude/docs/a02.xml": No such file or directory
3+
I/O warning : failed to load "test/XInclude/docs/a03.xml": No such file or directory
4+
I/O warning : failed to load "test/XInclude/docs/a04.xml": No such file or directory
5+
I/O warning : failed to load "test/XInclude/docs/a05.xml": No such file or directory
6+
I/O warning : failed to load "test/XInclude/docs/a06.xml": No such file or directory
7+
I/O warning : failed to load "test/XInclude/docs/a07.xml": No such file or directory
8+
I/O warning : failed to load "test/XInclude/docs/a08.xml": No such file or directory
9+
I/O warning : failed to load "test/XInclude/docs/a09.xml": No such file or directory
10+
I/O warning : failed to load "test/XInclude/docs/a10.xml": No such file or directory
11+
I/O warning : failed to load "test/XInclude/docs/a11.xml": No such file or directory
12+
I/O warning : failed to load "test/XInclude/docs/a12.xml": No such file or directory
13+
I/O warning : failed to load "test/XInclude/docs/a13.xml": No such file or directory
14+
I/O warning : failed to load "test/XInclude/docs/a14.xml": No such file or directory
15+
I/O warning : failed to load "test/XInclude/docs/a15.xml": No such file or directory
16+
I/O warning : failed to load "test/XInclude/docs/a16.xml": No such file or directory

result/XInclude/fallback6.xml.err

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
I/O error : failed to load "test/XInclude/docs/b.xml": No such file or directory
2-
I/O error : failed to load "test/XInclude/docs/c.xml": No such file or directory
1+
I/O warning : failed to load "test/XInclude/docs/b.xml": No such file or directory
2+
I/O warning : failed to load "test/XInclude/docs/c.xml": No such file or directory

result/XInclude/fallback7.xml.err

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
I/O error : failed to load "test/XInclude/without-reader/404.xml": No such file or directory
1+
I/O warning : failed to load "test/XInclude/without-reader/404.xml": No such file or directory

0 commit comments

Comments
 (0)