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

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [BUG?] XMLSERIALIZE( ... INDENT) won't work with blank nodes
Date: 2024-08-29 22:06:46
Message-ID: 76a8cb26-d13e-4731-a9f0-8bfebb96538d@uni-muenster.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v1-0001-Bug-fix-for-XMLSERIALIZE-.INDENT-for-xml-containi.patch text/x-patch 5.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2024-08-29 22:49:12 Re: allowing extensions to control planner behavior
Previous Message Jim Jones 2024-08-29 21:54:18 Re: [PATCH] Add CANONICAL option to xmlserialize