On 24.01.25 22:01, Chapman Flack wrote: > It seems to me the key connection there is that the ISO SQL standard > defines XMLDOCUMENT by equivalence to what `document { $expr }` means > in the W3 XML Query standard.
It seems I missed one sentence. My bad.
Next try... :)
The <function>xmldocument</function> function returns the input argument unchanged, or <literal>NULL</literal> if the argument is <literal>NULL</literal>, and is provided for compatibility.
The SQL-standard <replaceable>XMLDocument</replaceable> function applied to an XML value <literal>$EXPR</literal>, has effects equivalent to the XML Query expression <replaceable>document { $EXPR }</replaceable>. It replaces any document nodes in the input with their children and wraps the whole result in a single <replaceable>document node</replaceable>.
In the XML Query standard, a <replaceable>document node</replaceable> represents a relaxed version of an XML document structure. This corresponds to what PostgreSQL's single XML type allows, meaning that any valid non-null PostgreSQL XML value can be returned unchanged. Other systems may support more permissive XML data types, such as <literal>XML(SEQUENCE)</literal>, which allow values that do not conform to this structure. In PostgreSQL, every valid non-null value of the XML type already has that structure, making additional processing by this function unnecessary.
v6 attached.
I think so doc is ok now
because the function does nothing, then it is useless to convert input to XML and force detosting