[HACKERS] proposal - Default namespaces for XPath expressions (PostgreSQL 11) - Mailing list pgsql-hackers

From Pavel Stehule
Subject [HACKERS] proposal - Default namespaces for XPath expressions (PostgreSQL 11)
Date
Msg-id CAFj8pRB+WDyDcZyGmfRdJ0HOoXugeaL-KNFeK9YA5Z10JN9qfA@mail.gmail.com
Whole thread Raw
Responses Re: [HACKERS] proposal - Default namespaces for XPath expressions(PostgreSQL 11)
List pgsql-hackers
Hi

This proposal is followup of implementation of XMLTABLE. 

Lot of XML documents has assigned document namespace.
<rows xmlns="http://x.y"><row><a>10</a></row></rows>
For these XML document any search path must use schema "http://x.y". This is not too intuitive, and from XMLTABLE usage is not too user friendly, because the default column path (same like column name) cannot be used. A solution of this issue is default namespace - defined in SQL/XML.

example - related to previous xml

without default namespace:
XMLTABLE(NAMESPACES('http://x.y' AS aux),
                    '/aux:rows/aux:row' PASSING ...
                    COLUMNS a int PATH 'aux:a')

with default namespace
XMLTABLE(NAMESPACES(DEFAULT 'http://x.y'),
                    '/rows/row' PASSING ...
                    COLUMNS a int);


Unfortunately the libxml2 doesn't support default namespaces in XPath expressions. Because the libxml2 functionality is frozen, there is not big chance for support in near future. A implementation is not too hard - although it requires simple XPath expressions state translator.

The databases with XMLTABLE implementation supports default namespace for XPath expressions. 

The patch for initial implementation is attached. 

Regards

Pavel
Attachment

pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Re: [HACKERS] Need a builtin way to run all tests faster manner
Next
From: Andres Freund
Date:
Subject: Re: [HACKERS] Need a builtin way to run all tests faster manner