Re: Add XMLNamespaces to XMLElement - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: Add XMLNamespaces to XMLElement
Date
Msg-id CAFj8pRBf+fdsdBmtM6R2OS4vWDSy6BkgKOJ8ve-Ae1JAyQpF7Q@mail.gmail.com
Whole thread Raw
In response to Re: Add XMLNamespaces to XMLElement  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
Hi

st 15. 1. 2025 v 21:35 odesílatel Jim Jones <jim.jones@uni-muenster.de> napsal:
Hi Umar, Hi Pavel,

On 26.12.24 14:46, Jim Jones wrote:
> The idea of NO DEFAULT is pretty much to free an element (and its
> children) from a previous DEFAULT in the same scope.
>
> SELECT
>   xmlserialize(DOCUMENT
>     xmlelement(NAME "root",
>       xmlnamespaces(DEFAULT 'http:/x.y/ns1'),
>       xmlelement(NAME "foo",
>         xmlnamespaces(NO DEFAULT))
>   ) AS text INDENT);
>
>          xmlserialize         
> ------------------------------
>  <root xmlns="http:/x.y/ns1">+
>    <foo xmlns=""/>           +
>  </root>
> (1 row)

v3 is attached, now using xmlTextWriterWriteAttributeNS from libxml2 for
managing XML namespaces, instead of using xmlTextWriterWriteAttribute.
Libxml2 is quite lenient, allowing the duplication of default namespaces
within the same scope and even permitting NO DEFAULT namespaces when no
previous DEFAULT declaration has been made - both are semantically valid.

The crux now is finding the appropriate balance between accuracy and
user intent. In the context of PostgreSQL's xmlelement and
xmlnamespaces, I would argue that explicitly declared namespaces,
redundant or not, ought to be preserved. A user who intentionally
repeats a namespace declaration might have sound reasons for doing so,
like ensuring clarity, preserving compatibility with external XML
processors, or sticking to a specific schema. Silently omitting these
declarations could lead to confusion.


Now, I have not any objections against the code

The patch has doc and enough regress tests
The patching and compilation without problems
make check-world passed

I'll mark this patch as ready for committer


 
Pavel has tidied up the parser modifications - it's looking much neater
now. Many thanks for that!

It was a pleasure

Regards

Pavel

Best, Jim

pgsql-hackers by date:

Previous
From: Michael Banck
Date:
Subject: Re: [PATCH] New predefined role pg_manage_extensions
Next
From: Alena Rybakina
Date:
Subject: Re: Eagerly scan all-visible pages to amortize aggressive vacuum