xpath_array with namespaces support

From: "Nikolay Samokhvalov" <samokhvalov(at)gmail(dot)com>
To: PGSQL-Patches <pgsql-patches(at)postgresql(dot)org>
Subject: xpath_array with namespaces support
Date: 2007-02-20 23:46:33
Message-ID: e431ff4c0702201546h2b0ce0bcn4da1363ede18aab1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

As a result of discussion with Peter, I provide modified patch for
xpath_array() with namespaces support.

The signature is:
_xml xpath_array(text xpathQuery, xml xmlValue[, _text namespacesBindings])

The third argument is 2-dimensional array defining bindings for
namespaces. Simple examples:

xmltest=# SELECT xpath_array('//text()', '<local:data
xmlns:local="http://127.0.0.1"><local:piece id="1">number
one</local:piece><local:piece id="2" /></local:data>');
xpath_array
----------------
{"number one"}
(1 row)

xmltest=# SELECT xpath_array('//loc:piece/@id', '<local:data
xmlns:local="http://127.0.0.1"><local:piece id="1">number
one</local:piece><local:piece id="2" /></local:data>',
ARRAY[ARRAY['loc'], ARRAY['http://127.0.0.1']]);
xpath_array
-------------
{1,2}
(1 row)

Thoughts regarding other XPath functions were exposed a couple of days
ago: http://archives.postgresql.org/pgsql-patches/2007-02/msg00373.php

If there is no objections, we could call the function provided in this
patch as xpath() or xmlpath() (the latter is similar to SQL/XML
functions).

Also, maybe someone can suggest better approach for passing namespace
bindings (more convenient than ARRAY[ARRAY[...], ARRAY[...]])?

--
Best regards,
Nikolay

Attachment Content-Type Size
xpath.w.namespaces.20070220.patch text/x-patch 9.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeremy Drake 2007-02-20 23:49:49 Re: [pgsql-patches] [HACKERS] less privileged pl install
Previous Message Bruce Momjian 2007-02-20 23:39:12 Re: PrivateRefCount (for 8.3)

Browse pgsql-patches by date

  From Date Subject
Next Message Jeremy Drake 2007-02-20 23:49:49 Re: [pgsql-patches] [HACKERS] less privileged pl install
Previous Message Bruce Momjian 2007-02-20 22:47:03 Re: [pgsql-patches] O_DIRECT support for Windows