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

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Subject: Re: [BUG?] XMLSERIALIZE( ... INDENT) won't work with blank nodes
Date: 2024-09-06 11:55:06
Message-ID: 90489bfb-941d-46a9-a20f-65644290bf21@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)
>

mmh... xmlDocContentDumpOutput seems to add a trailing newline in the
end of a document by default, making the serialization of the same xml
string with DOCUMENT and CONTENT different:

-- postgres v16

SELECT xmlserialize(CONTENT '<foo><bar>42</bar></foo>' AS text INDENT);
  xmlserialize   
-----------------
 <foo>          +
   <bar>42</bar>+
 </foo>
(1 row)

SELECT xmlserialize(DOCUMENT '<foo><bar>42</bar></foo>' AS text INDENT);
  xmlserialize   
-----------------
 <foo>          +
   <bar>42</bar>+
 </foo>         +
 
(1 row)

I do recall a discussion along these lines some time ago, but I just
can't find it now. Does anyone know if this is the expected behaviour?
Or should we in this case consider something like this in
xmltotext_with_options()?

result = cstring_to_text_with_len((const char *) xmlBufferContent(buf),
xmlBufferLength(buf) - 1);

--
Jim

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jakub Wartak 2024-09-06 11:56:58 Re: scalability bottlenecks with (many) partitions (and more)
Previous Message Nisha Moond 2024-09-06 11:40:21 Re: Conflict Detection and Resolution