pg.ddx.io pgsql-docs@postgresql.org mailing list archive
help / color / mirror / Atom feedMore clearly on XML namespaces inside xpath function
2+ messages / 2 participants
[nested] [flat]
* More clearly on XML namespaces inside xpath function
@ 2010-06-04 09:51 Nikolay Samokhvalov <samokhvalov@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Samokhvalov @ 2010-06-04 09:51 UTC (permalink / raw)
To: pgsql-docs
Explain how to deal with XML namespaces inside the "xpath" function
(especially about "default" namespaces, what is really unclear at first
glance).
inline patch 1: func.sgml, func.sgml 4 Jun 2010 09:48:44 -0000 (+1/-2 lines) download inline-1.patch
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
<function>xpath</function>
+ function context, aliases are <emphasis>local</>).
</para>
<para>
@@ -8612,6 +8615,19 @@
(1 row)
]]></screen>
</para>
+
+ <para>
+ How to deal with default (anonymous) namespaces:
+<screen><![CDATA[
+SELECT xpath('//mydefns:b/text()', '<a xmlns="http://example.com
"><b>test</b></a>',
+ ARRAY[ARRAY['mydefns', 'http://example.com';]]);
+
+ xpath
+--------
+ {test}
+(1 row)
+]]></screen>
+ </para>
</sect2>
<sect2 id="functions-xml-mapping">
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: More clearly on XML namespaces inside xpath function
@ 2010-07-03 17:21 Bruce Momjian <bruce@momjian.us>
parent: Nikolay Samokhvalov <samokhvalov@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: Bruce Momjian @ 2010-07-03 17:21 UTC (permalink / raw)
To: Nikolay Samokhvalov <samokhvalov@gmail.com>; +Cc: pgsql-docs
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
> <function>xpath</function>
> + function context, aliases are <emphasis>local</>).
> </para>
>
> <para>
> @@ -8612,6 +8615,19 @@
> (1 row)
> ]]></screen>
> </para>
> +
> + <para>
> + How to deal with default (anonymous) namespaces:
> +<screen><![CDATA[
> +SELECT xpath('//mydefns:b/text()', '<a xmlns="http://example.com
> "><b>test</b></a>',
> + ARRAY[ARRAY['mydefns', 'http://example.com';]]);
> +
> + xpath
> +--------
> + {test}
> +(1 row)
> +]]></screen>
> + </para>
> </sect2>
>
> <sect2 id="functions-xml-mapping">
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ None of us is going to be here forever. +
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2010-07-03 17:21 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-06-04 09:51 More clearly on XML namespaces inside xpath function Nikolay Samokhvalov <samokhvalov@gmail.com>
2010-07-03 17:21 ` Bruce Momjian <bruce@momjian.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox