Hi,

Issue is described here

https://stackoverflow.com/questions/71408524/get-list-of-nodenames-in-postgresql-xpath

 

version:

"PostgreSQL 14.1, compiled by Visual C++ build 1914, 64-bit"

 

Request

 

SELECT xpath('name()', '<name1><name2>test1</name2><name3>test2</name3></name1>')::varchar;

 

returns an empty list,  but is expected to return name of the element (as it does in 9.6 version).

 

Same result occurs while calling

 

SELECT xpath('name()', unnest(xpath('//*', '<foo><bar>test</bar><zar>test1</zar></foo>')));

 

It returns empty list.

 

Meanwhile request

 

SELECT * FROM

                XMLTABLE('//*' PASSING '<foo><bar>test</bar><zar>test1</zar></foo>'

                                                COLUMNS

                                                name varchar PATH 'name()');

 

rightfully returns list of element names.

 

It looks like XPATH name() function called from xpath() PostgreSQL function behave differently than when called from XMLTABLE() PATH

This behavior is different from that of 9.6 version where xpath correctly returns names of the nodes.

Same issue refers to local-name(), namespace-uri()  XPath functions.

 

 

Best regards,

Andrey Kapliev