Re: [BUG?] XMLSERIALIZE( ... INDENT) won't work with blank nodes

Jim Jones <jim.jones@uni-muenster.de>

From: Jim Jones <jim.jones@uni-muenster.de>
To: pgsql-hackers@lists.postgresql.org
Date: 2024-08-29T22:06:46Z
Lists: pgsql-hackers

Attachments


On 28.08.24 10:19, Jim Jones wrote:
> Hi,
>
> While testing a feature reported by Pavel in this thread[1] I realized
> that elements containing whitespaces between them won't be indented with
> XMLSERIALIZE( ... INDENT)
>
> SELECT xmlserialize(DOCUMENT '<foo><bar>42</bar></foo>' AS text INDENT);
>
>   xmlserialize   
> -----------------
>  <foo>          +
>    <bar>42</bar>+
>  </foo>         +
>  
> (1 row)
>
> SELECT xmlserialize(DOCUMENT '<foo> <bar>42</bar> </foo>'::xml AS text
> INDENT);
>         xmlserialize        
> ----------------------------
>  <foo> <bar>42</bar> </foo>+
>  
> (1 row)
>
>
> Other products have a different approach[2]
>
> Perhaps simply setting xmltotext_with_options' parameter "perserve_whitespace" to false when XMLSERIALIZE(.. INDENT) would do the trick.
>
> doc = xml_parse(data, xmloption_arg, !indent ? true : false,
> 			GetDatabaseEncoding(),
> 			&parsed_xmloptiontype, &content_nodes,
> 			(Node *) &escontext);
>
>
> (diff attached)
>
> SELECT xmlserialize(DOCUMENT '<foo> <bar>42</bar> </foo>'::xml AS text
> INDENT);
>   xmlserialize   
> -----------------
>  <foo>          +
>    <bar>42</bar>+
>  </foo>         +
>  
> (1 row)
>
> If this is indeed the way to go I can update the regression tests accordingly.
>
> Best,
>

Just created a CF entry for this: https://commitfest.postgresql.org/49/5217/
v1 attached includes regression tests.

-- 
Jim

Commits

  1. Fix some whitespace issues in XMLSERIALIZE(... INDENT).