Re: [PATCH] Add pretty-printed XML output option - Mailing list pgsql-hackers

From Jim Jones
Subject Re: [PATCH] Add pretty-printed XML output option
Date
Msg-id 4c2efca5-8257-2424-6687-07c65e319e95@uni-muenster.de
Whole thread Raw
In response to Re: [PATCH] Add pretty-printed XML output option  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
Responses Re: [PATCH] Add pretty-printed XML output option
Re: [PATCH] Add pretty-printed XML output option
List 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

pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: improving user.c error messages
Next
From: Stephen Frost
Date:
Subject: Re: Weird failure with latches in curculio on v15[