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

From Pavel Stehule
Subject Re: XMLDocument (SQL/XML X030)
Date
Msg-id CAFj8pRB=Rv8tByf3TWTooO7MBVM2F=xCNMAgOTK6BM1e0uq-DQ@mail.gmail.com
Whole thread Raw
In response to Re: XMLDocument (SQL/XML X030)  (Jim Jones <jim.jones@uni-muenster.de>)
Responses Re: XMLDocument (SQL/XML X030)
List pgsql-hackers


pá 24. 1. 2025 v 9:12 odesílatel Jim Jones <jim.jones@uni-muenster.de> napsal:
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?

I don't know what it means - `function returns a document node` in the context of Postgres implementation of XML.
I miss the information so it returns an input argument without changing anything, because in a system, where XML expression
holds a complete string (not graph like some other systems), it just does nothing.

If somebody looks the source code, then he should be in panic mode, because the doc talks about returning "document node",
and it is just an argument. So it should be explained more in PostgreSQL XML design, and less in SQL/XML description. Because
In this case, SQL/XML description (in postgresql context) is absolutely confusing.

Regards

Pavel



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

pgsql-hackers by date:

Previous
From: Bertrand Drouvot
Date:
Subject: Re: doc: explain pgstatindex fragmentation
Next
From: Sergey Tatarintsev
Date:
Subject: Re: create subscription with (origin = none, copy_data = on)