Re: XMLDocument (SQL/XML X030) - Mailing list pgsql-hackers

From Jim Jones
Subject Re: XMLDocument (SQL/XML X030)
Date
Msg-id 9198dc35-67bc-4fa7-ad0a-fc7c1eca3581@uni-muenster.de
Whole thread Raw
In response to Re: XMLDocument (SQL/XML X030)  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: XMLDocument (SQL/XML X030)
List pgsql-hackers
Hi

On 24.01.25 07:28, Pavel Stehule wrote:
> I think documentation should be strongly enhanced. This is probably
> the hardest part of this patch - explain well what this function does
> and what it doesn't.

You mean something like this? Or perhaps something more technical?

The <function>xmldocument</function> function returns a document node,
representing an XML document, from the provided <type>xml</type>
expression. The input expression can represent any valid XML content,
including elements, text, or a sequence of nodes. If the
<type>xml</type> expression is NULL, the function returns NULL. This
function does not require the input to have a single root node or
encapsulate the result in a root element. The validation of the
<type>xml</type> expression depends on the current <xref
linkend="guc-xmloption"/> setting.

Example:

WITH xmldata (val) AS (
  VALUES
    (xmlparse(DOCUMENT '<root><foo>bar</foo></root>')),
    (xmltext('foo&bar')),
    (xmlelement(NAME el)),
    (xmlforest(42 AS foo, 73 AS bar))
)
SELECT xmldocument(val) FROM xmldata;

         xmldocument
-----------------------------
 <root><foo>bar</foo></root>
 foo&bar
 <el/>
 <foo>42</foo><bar>73</bar>
(4 rows)


Thanks!

Best, Jim




pgsql-hackers by date:

Previous
From: Lukas Fittl
Date:
Subject: Re: [PATCH] Optionally record Plan IDs to track plan changes for a query
Next
From: Ashutosh Bapat
Date:
Subject: Re: Enhance 'pg_createsubscriber' to retrieve databases automatically when no database is provided.