Xmllint prints "warning", but shouldn't it be "error"?

If the input file does not exist:

$ xmllint foo.xml
warning: failed to load external entity "foo.xml"

I don’t see how that is not an error. It even has non-zero exit code:

$ echo $?
1

And its not just this particular example above. It seems that errors are prefixed with warning.

$ XML_CATALOG_FILES=~/xsd_ler/mycatalog.xml \
xmllint --noout --nowarning \
    --schema ~/xsd_ler/2.0_ler.xsd \
    test.gml
warning: failed to load external entity "https://schemas.isotc211.org/19139/-/gmx/1.0/gmx.xsd"
/home/velle/xsd_ler/2.0_ler.xsd:19: element import: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}import': Failed to parse the XML resource 'https://schemas.isotc211.org/19139/-/gmx/1.0/gmx.xsd'.
WXS schema /home/velle/xsd_ler/2.0_ler.xsd failed to compile

And if I use the --nowarning flag those “warnings” are still printed, while the output without any prefix are suppressed.

It seems to me that errors are given the wrong prefix when printed, and that the warnings are given no prefix.

Could you please help me understand this?

Details below:

$ xmllint --version
xmllint: using libxml version 20913
   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Unicode Regexps Automata Schemas Schematron Modules Debug Zlib Lzma 
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.3 LTS
Release:	22.04
Codename:	jammy

You’re right. These warnings should be errors but it’s mostly a cosmetic issue.

If one is a newbie, as I am, it is not only cosmetic :slight_smile: It is confusing/misleading. I will report this as an issue. It should be easy to fix, I assume? Sincerely

Created ticket: Xmllint prints “warning” instead of "error", and leaves out "warning" for actual warnings (#667) · Issues · GNOME / libxml2 · GitLab

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.