Fix some whitespace issues in XMLSERIALIZE(... INDENT).
commit946f150aa180ec61d37d7a41e43765b4c25ca784
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 10 Sep 2024 20:20:31 +0000 (10 16:20 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 10 Sep 2024 20:20:31 +0000 (10 16:20 -0400)
tree6510fdc154e6e20f50fb61c20f2e3dac6c46bcfa
parent77aebe9a8d3cccd4c54b43be87a38f2bae614c76
Fix some whitespace issues in XMLSERIALIZE(... INDENT).

We must drop whitespace while parsing the input, else libxml2
will include "blank" nodes that interfere with the desired
indentation behavior.  The end result is that we didn't indent
nodes separated by whitespace.

Also, it seems that libxml2 may add a trailing newline when working
in DOCUMENT mode.  This is semantically insignificant, so strip it.

This is in the gray area between being a bug fix and a definition
change.  However, the INDENT option is still pretty new (since v16),
so I think we can get away with changing this in stable branches.
Hence, back-patch to v16.

Jim Jones

Discussion: https://postgr.es/m/872865a8-548b-48e1-bfcd-4e38e672c1e4@uni-muenster.de
src/backend/utils/adt/xml.c
src/test/regress/expected/xml.out
src/test/regress/expected/xml_1.out
src/test/regress/expected/xml_2.out
src/test/regress/sql/xml.sql