After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 565370 - xmllint succesful validation should send message to stdout rather than stderr
xmllint succesful validation should send message to stdout rather than stderr
Status: RESOLVED OBSOLETE
Product: libxml2
Classification: Platform
Component: xmllint
2.7.1
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2008-12-22 17:48 UTC by Bernard Desgraupes
Modified: 2021-07-05 13:26 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Bernard Desgraupes 2008-12-22 17:48:46 UTC
Please describe the problem:
When performing a validation against a Relax NG or an XSD schema, if the validation succeeds, xmllint prints the message:
"/path/to/file validates"
The problem is that this string is written on stderr rather than stdout.

I'm a developer of the AlphaX text editor (on Mac OS X) which contains a Tcl language interpreter. I'm currently implementing an XML mode for AlphaX: this makes use of the Tcl [exec] command which executes xmllint. When a message arrives on stderr, [exec] raises an error: this means that we have no way to detect that a document validates.

I suggest that in case of success the string be written on stdout. There are five instructions in the source file xmllint.c:
l.1667			fprintf(stderr, "%s validates\n", filename);
l.1936			fprintf(stderr, "%s validates\n", filename);
l.2680		    fprintf(stderr, "%s validates\n", filename);
l.2711		    fprintf(stderr, "%s validates\n", filename);
l.2739		    fprintf(stderr, "%s validates\n", filename);

(These line numbers correspond to the 2.7.2 sources)


Steps to reproduce:
1. lauch a tcl shell:
shell> tclsh
2. execute a command like this with files which are expected to validate:
% catch {exec xmllint --relaxng file.rng file.xml} result

3. read the result
% set result 
"file.xml validates" 


Actual results:
The return value of the [catch] will be 1 which means an error has been caught.

Expected results:
It should normally be 0 when everything goes right. This way, one can distinguish successful validation from failure with the following construct (which is most common in Tcl scripts):
if {[catch {exec xmllint --relaxng file.rng file.xml}] result} {
# do something on failure
} else {
# do something on success
}


Does this happen every time?
yes

Other information:
The fix is very easy: replace stderr by stdout when ret == 0, i-e when the document validates.
Comment 1 GNOME Infrastructure Team 2021-07-05 13:26:08 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/libxml2/-/issues/

Thank you for your understanding and your help.