1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Support [NO] INDENT option in XMLSERIALIZE().

This adds the ability to pretty-print XML documents ... according to
libxml's somewhat idiosyncratic notions of what's pretty, anyway.
One notable divergence from a strict reading of the spec is that
libxml is willing to collapse empty nodes "<node></node>" to just
"<node/>", whereas SQL and the underlying XML spec say that this
option should only result in whitespace tweaks.  Nonetheless,
it seems close enough to justify using the SQL-standard syntax.

Jim Jones, reviewed by Peter Smith and myself

Discussion: https://postgr.es/m/2f5df461-dad8-6d7d-4568-08e10608a69b@uni-muenster.de
This commit is contained in:
Tom Lane
2023-03-15 16:58:59 -04:00
parent 419a8dd814
commit 483bdb2afe
15 changed files with 775 additions and 22 deletions

View File

@ -4460,7 +4460,7 @@ xml '<foo>bar</foo>'
<type>xml</type>, uses the function
<function>xmlserialize</function>:<indexterm><primary>xmlserialize</primary></indexterm>
<synopsis>
XMLSERIALIZE ( { DOCUMENT | CONTENT } <replaceable>value</replaceable> AS <replaceable>type</replaceable> )
XMLSERIALIZE ( { DOCUMENT | CONTENT } <replaceable>value</replaceable> AS <replaceable>type</replaceable> [ [ NO ] INDENT ] )
</synopsis>
<replaceable>type</replaceable> can be
<type>character</type>, <type>character varying</type>, or
@ -4470,6 +4470,13 @@ XMLSERIALIZE ( { DOCUMENT | CONTENT } <replaceable>value</replaceable> AS <repla
you to simply cast the value.
</para>
<para>
The <literal>INDENT</literal> option causes the result to be
pretty-printed, while <literal>NO INDENT</literal> (which is the
default) just emits the original input string. Casting to a character
type likewise produces the original string.
</para>
<para>
When a character string value is cast to or from type
<type>xml</type> without going through <type>XMLPARSE</type> or