Re: [xml] xmllint: Exit code 0 despite undefined namespace prefix



I wondered about that as well a while back.
The manpage specifies the exit statuses below.  The document is well-formed and shouldn't fail to parse because the namespace-prefix separating ':' was always allowed as part of a tag name iirc.
There's no schema, so it's not a schema validation issue.
There's no exit status that would reasonably  be returned, though stderr says it's a namespace 'error', so "0 No error" also doesn't seem completely correct.
However, I've seen multiple applications that rely on xmllint *not* exiting other-than-0 due to missing namespace prefixes.
Could possibly double-pass it with xmllint file 2>&1 > /dev/null | grep namespace.error


DIAGNOSTICS
       xmllint return codes provide information that can be used when calling it from scripts.

       0
           No error

       1
           Unclassified

       2
           Error in DTD

       3
           Validation error

       4
           Validation error

       5
           Error in schema compilation

       6
           Error writing output

       7
           Error in pattern (generated when --pattern option is used)

       8
           Error in Reader registration (generated when --chkregister option is used)

       9
           Out of memory error

On Sun, Jun 20, 2021 at 11:59 PM Christian Weiske via xml <xml gnome org> wrote:
Hello,


I'm using xmllint to validate files automatically during CI runs, and
now an error was not catched.

The xml file used a namespace prefix that was not defined. xmllint
noticed that, but still gave an exit code of 0:

> $ xmllint --noout text.xml; echo $?
> text.xml:66: namespace error : Namespace prefix v on tag is not defined
>         <v:tag/>
>               ^
> 0

Is there a way to make xmllint use a non-0 exit code in this case?

(Happens on Ubuntu Linux 20.04:
xmllint: using libxml version 20912
    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
)

--
Regards/Mit freundlichen Grüßen
Christian Weiske

-=≡ Geeking around in the name of science since 1982 ≡=-
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
https://mail.gnome.org/mailman/listinfo/xml


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]