| 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: | [BUG?] XMLSERIALIZE( ... INDENT) won't work with blank nodes |
| Date: | 2024-08-28 08:19:48 |
| Message-ID: | 872865a8-548b-48e1-bfcd-4e38e672c1e4@uni-muenster.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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,
--
Jim
1 - https://www.postgresql.org/message-id/cbd68a31-9776-4742-9c09-4344a4c5e6dc%40uni-muenster.de
2 - https://dbfiddle.uk/zdKnfsqX
| Attachment | Content-Type | Size |
|---|---|---|
| remove-blanknodes-in-xmlserialize-indent.diff | text/x-patch | 876 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2024-08-28 08:47:32 | Re: Detailed release notes |
| Previous Message | Kirill Reshke | 2024-08-28 08:18:13 | [BUG?] WAL file archive leads to crash during startup |