Re: XMLDocument (SQL/XML X030)

From: Chapman Flack <jcflack(at)acm(dot)org>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: 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 15:49:34
Message-ID: 6793B68E.7050904@acm.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 01/24/25 08:48, Jim Jones wrote:
> In the SQL/XML specification, the XMLDocument (X030) function is
> designed to return a document node from a given XML value expression.

Maybe we can take advantage of the way that specifications usually
don't mandate an implementation, but only results equivalent to
an implementation. So we could say something like:

The function `xmldocument` returns the input argument unchanged,
null if the argument is null, and is supplied for compatibility.

The SQL-standard `XMLDOCUMENT` function applied to an XML value
/expr/ has effects equivalent to the XML Query expression
`document { /expr/ }`, specified to replace any document nodes
in the input with their children and wrap the whole result in one
document node. An XML Query "document node" is a relaxed version
of XML document structure, which need not have exactly one child
element node, and also allows text nodes as children.

Some systems support a family of XML data types including
`XML(SEQUENCE)`, which can hold values that do not have such a
structure. In PostgreSQL, every valid non-null value of the single
`XML` type already has that structure, and so is returned by this
function unchanged.

Regards,
-Chap

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2025-01-24 15:55:25 Re: Orphaned users in PG16 and above can only be managed by Superusers
Previous Message Tom Lane 2025-01-24 15:48:53 Re: Casts from jsonb to other types should cope with json null