Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 92E6D6346C8 for ; Sat, 3 Jul 2010 14:31:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 97291-01-3 for ; Sat, 3 Jul 2010 17:31:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from momjian.us (momjian.us [70.90.9.53]) by mail.postgresql.org (Postfix) with ESMTP id CBF7A640387 for ; Sat, 3 Jul 2010 14:21:54 -0300 (ADT) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id o63HLsW02254; Sat, 3 Jul 2010 13:21:54 -0400 (EDT) From: Bruce Momjian Message-Id: <201007031721.o63HLsW02254@momjian.us> Subject: Re: More clearly on XML namespaces inside xpath function In-Reply-To: To: Nikolay Samokhvalov Date: Sat, 3 Jul 2010 13:21:54 -0400 (EDT) CC: PostgreSQL-documentation X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.011 tagged_above=-5 required=5 tests=BAYES_20=-0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/35 X-Sequence-Number: 5691 Thanks, applied. --------------------------------------------------------------------------- Nikolay Samokhvalov wrote: > Explain how to deal with XML namespaces inside the "xpath" function > (especially about "default" namespaces, what is really unclear at first > glance). > > > Index: func.sgml > =================================================================== > RCS file: /projects/cvsroot/pgsql/doc/src/sgml/func.sgml,v > retrieving revision 1.516 > diff -u -r1.516 func.sgml > --- func.sgml 3 Jun 2010 14:40:42 -0000 1.516 > +++ func.sgml 4 Jun 2010 09:48:44 -0000 > @@ -8596,8 +8596,11 @@ > mappings. This array should be a two-dimensional array with the > length of the second axis being equal to 2 (i.e., it should be an > array of arrays, each of which consists of exactly 2 elements). > - The first element of each array entry is the namespace name, the > - second the namespace URI. > + The first element of each array entry is the namespace name (alias), > the > + second the namespace URI. It is not required that aliases provided in > + this array are the same that those being used in the XML document > itself (in > + other words, both in the XML document and in the > xpath > + function context, aliases are local). > > > > @@ -8612,6 +8615,19 @@ > (1 row) > ]]> > > + > + > + How to deal with default (anonymous) namespaces: > + +SELECT xpath('//mydefns:b/text()', 'test', > + ARRAY[ARRAY['mydefns', 'http://example.com']]); > + > + xpath > +-------- > + {test} > +(1 row) > +]]> > + > > > -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + None of us is going to be here forever. +