Re: XMLDocument (SQL/XML X030)

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Chapman Flack <jcflack(at)acm(dot)org>, Robert Treat <rob(at)xzilla(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: XMLDocument (SQL/XML X030)
Date: 2025-01-24 08:11:59
Message-ID: 9198dc35-67bc-4fa7-ad0a-fc7c1eca3581@uni-muenster.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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&amp;bar
 <el/>
 <foo>42</foo><bar>73</bar>
(4 rows)

Thanks!

Best, Jim

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Oliver Ford 2025-01-24 08:27:09 Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options
Previous Message Srinath Reddy 2025-01-24 08:04:19 Re: why -Fdance archive format option works with ./pg_restore but not with ./pg_dump?