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