From: | Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> |
---|---|
To: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Smith <smithpb2250(at)gmail(dot)com>, Andrey Borodin <amborodin86(at)gmail(dot)com> |
Subject: | Re: [PATCH] Add pretty-printed XML output option |
Date: | 2023-02-20 23:06:05 |
Message-ID: | 4c2efca5-8257-2424-6687-07c65e319e95@uni-muenster.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 18.02.23 19:09, Peter Eisentraut wrote:
> On 17.02.23 23:24, Nikolay Samokhvalov wrote:
>>
>> My idea was to follow the SQL standard (part 14, SQL/XML);
>> unfortunately, there is no free version, but there are drafts at
>> http://www.wiscorp.com/SQLStandards.html
>> <http://www.wiscorp.com/SQLStandards.html>.
>>
>> <XML character string serialization> ::= XMLSERIALIZE <left paren> [
>> <document or content> ]
>>
>> <XML value expression> AS <data type> [ <XML serialize bom> ] [ <XML
>> serialize version> ] [ <XML declaration option> ]
>>
>> [ <XML serialize indent> ] <right paren>
>>
>> <XML serialize indent> ::= [ NO ] INDENT
>
> Good find. It would be better to use this standard syntax.
As suggested by Peter and Nikolay, v15 now removes the xmlformat
function from the catalog and adds the [NO] INDENT option to
xmlserialize, as described in X069.
postgres=# SELECT xmlserialize(DOCUMENT '<foo><bar><val
x="y">42</val></bar></foo>' AS text INDENT);
xmlserialize
----------------------------------------
<?xml version="1.0" encoding="UTF-8"?>+
<foo> +
<bar> +
<val x="y">42</val> +
</bar> +
</foo> +
(1 row)
postgres=# SELECT xmlserialize(DOCUMENT '<foo><bar><val
x="y">42</val></bar></foo>' AS text NO INDENT);
xmlserialize
-------------------------------------------
<foo><bar><val x="y">42</val></bar></foo>
(1 row)
Although the indent feature is designed to work with xml strings of type
DOCUMENT, this implementation also allows the usage of CONTENT type
strings as long as it contains a well-formed xml. It will throw an error
otherwise.
Thanks!
Best, Jim
Attachment | Content-Type | Size |
---|---|---|
v15-0001-Add-pretty-printed-XML-output-option.patch | text/x-patch | 22.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2023-02-20 23:17:21 | Re: Weird failure with latches in curculio on v15[ |
Previous Message | Nathan Bossart | 2023-02-20 22:58:52 | Re: improving user.c error messages |