Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 62CB6632726 for ; Fri, 4 Jun 2010 06:58:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 33592-04 for ; Fri, 4 Jun 2010 09:58:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wy0-f174.google.com (mail-wy0-f174.google.com [74.125.82.174]) by mail.postgresql.org (Postfix) with ESMTP id E62D76323FA for ; Fri, 4 Jun 2010 06:58:35 -0300 (ADT) Received: by wyi11 with SMTP id 11so704900wyi.19 for ; Fri, 04 Jun 2010 02:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=jC8OZfZOO4kIybFbYpjdxksQFj6C3C1NOZpZD6Ms3DA=; b=v0kfzRPsQ6S76QtPKVI9cfXmNzdNlmxnMgLdUfBZUhQQjxleVY5B7CgXKG2bxMvKY8 ols0zuTvSAnKNHmzLnepuqGE6T7m+A0zjO8OiuUrA/WVpS2yFfkiloG9hZxrWxOAn9F4 vzEXPKlbMOM51RqB/y6FB805I44QgAHB3Nm0Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=s9VQIPPPhcIFT4Nx9EE0hPheAarSmBMR6ghRgJy9O0XHCuSetsDe0qwnwI0oIadtPM 46ymsrvXJRd2bfcQvimPclj4wo+gVXRbB/602aQAm7OTBS+STQSbwRk5wW3zUJDXrWjX JXISAI/48sjJHVxYtFHl6LRa+fZSkylPOzwLQ= Received: by 10.216.91.15 with SMTP id g15mr2143685wef.15.1275645081194; Fri, 04 Jun 2010 02:51:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.154.141 with HTTP; Fri, 4 Jun 2010 02:51:01 -0700 (PDT) From: Nikolay Samokhvalov Date: Fri, 4 Jun 2010 13:51:01 +0400 Message-ID: Subject: More clearly on XML namespaces inside xpath function To: PostgreSQL-documentation Content-Type: multipart/alternative; boundary=0016e6d566adec915704883143bd X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.801 tagged_above=-5 required=5 tests=BAYES_50=0.8, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201006/5 X-Sequence-Number: 5573 --0016e6d566adec915704883143bd Content-Type: text/plain; charset=UTF-8 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: +test', + ARRAY[ARRAY['mydefns', 'http://example.com']]); + + xpath +-------- + {test} +(1 row) +]]> + --0016e6d566adec915704883143bd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Explain how to deal with XML namespaces inside the "xpath" f= unction (especially about "default" namespaces, what is really un= clear at first glance).


Index:= func.sgml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS fil= e: /projects/cvsroot/pgsql/doc/src/sgml/func.sgml,v
retrieving re= vision 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 @@
=C2=A0=C2=A0 =C2=A0 mappings. =C2=A0T= his array should be a two-dimensional array with the
=C2=A0=C2=A0= =C2=A0 length of the second axis being equal to 2 (i.e., it should be an
=C2=A0=C2=A0 =C2=A0 array of arrays, each of which consists of exa= ctly 2 elements).
- =C2=A0 =C2=A0The first element of each array entry is the namespace = name, the
- =C2=A0 =C2=A0second the namespace URI.
+ = =C2=A0 =C2=A0The first element of each array entry is the namespace name (a= lias), the
+ =C2=A0 =C2=A0second the namespace URI. It is not req= uired that aliases provided in
+ =C2=A0 =C2=A0this array are the same that those being used in the XM= L document itself (in
+ =C2=A0 =C2=A0other words, both in the XML= document and in the <function>xpath</function>
+ =C2= =A0 =C2=A0function context, aliases are <emphasis>local</>).
=C2=A0=C2=A0 =C2=A0</para>
=C2=A0
=C2=A0=C2= =A0 =C2=A0<para>
@@ -8612,6 +8615,19 @@
=C2=A0(1 = row)
=C2=A0]]></screen>
=C2=A0=C2=A0 =C2=A0<= ;/para>
+ =C2=A0=C2=A0
+ =C2=A0 <para>
+ =C2=A0 =C2=A0How to deal with default (anonymous) namespaces:
<= div>+<screen><![CDATA[
+SELECT xpath('//mydefns:b/te= xt()', '<a xmlns=3D"http://e= xample.com"><b>test</b></a>',=C2=A0
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ARRAY[ARRAY['mydefns&#= 39;, 'http://example.com']]);
+
+ xpath =C2=A0
+--------
+ {test}
+(1 row)
+]]></screen>
+ =C2=A0 </para>
=C2=A0=C2=A0 </sect2>
=C2=A0
=C2=A0=C2=A0 <sect2 id=3D"functions-xml-mapping&q= uot;>

--0016e6d566adec915704883143bd--