@@ -10328,50 +10328,53 @@ SELECT xml_is_well_formed_document('<pg:foo xmlns:pg="http://postgresql.org/stuf
10328
10328
<sect2 id="functions-xml-processing">
10329
10329
<title>Processing XML</title>
10330
10330
10331
- <indexterm>
10332
- <primary>XPath</primary>
10333
- </indexterm>
10334
-
10335
10331
<para>
10336
10332
To process values of data type <type>xml</type>, PostgreSQL offers
10337
10333
the functions <function>xpath</function> and
10338
10334
<function>xpath_exists</function>, which evaluate XPath 1.0
10339
10335
expressions.
10340
10336
</para>
10341
10337
10338
+ <sect3 id="functions-xml-processing-xpath">
10339
+ <title><literal>xpath</literal></title>
10340
+
10341
+ <indexterm>
10342
+ <primary>XPath</primary>
10343
+ </indexterm>
10344
+
10342
10345
<synopsis>
10343
10346
<function>xpath</function>(<replaceable>xpath</replaceable>, <replaceable>xml</replaceable> <optional>, <replaceable>nsarray</replaceable></optional>)
10344
10347
</synopsis>
10345
10348
10346
- <para>
10347
- The function <function>xpath</function> evaluates the XPath
10348
- expression <replaceable>xpath</replaceable> (a <type>text</> value)
10349
- against the XML value
10350
- <replaceable>xml</replaceable>. It returns an array of XML values
10351
- corresponding to the node set produced by the XPath expression.
10352
- If the XPath expression returns a scalar value rather than a node set,
10353
- a single-element array is returned.
10354
- </para>
10349
+ <para>
10350
+ The function <function>xpath</function> evaluates the XPath
10351
+ expression <replaceable>xpath</replaceable> (a <type>text</> value)
10352
+ against the XML value
10353
+ <replaceable>xml</replaceable>. It returns an array of XML values
10354
+ corresponding to the node set produced by the XPath expression.
10355
+ If the XPath expression returns a scalar value rather than a node set,
10356
+ a single-element array is returned.
10357
+ </para>
10355
10358
10356
- <para>
10357
- The second argument must be a well formed XML document. In particular,
10358
- it must have a single root node element.
10359
- </para>
10359
+ <para>
10360
+ The second argument must be a well formed XML document. In particular,
10361
+ it must have a single root node element.
10362
+ </para>
10360
10363
10361
- <para>
10362
- The optional third argument of the function is an array of namespace
10363
- mappings. This array should be a two-dimensional <type>text</> array with
10364
- the length of the second axis being equal to 2 (i.e., it should be an
10365
- array of arrays, each of which consists of exactly 2 elements).
10366
- The first element of each array entry is the namespace name (alias), the
10367
- second the namespace URI. It is not required that aliases provided in
10368
- this array be the same as those being used in the XML document itself (in
10369
- other words, both in the XML document and in the <function>xpath</function>
10370
- function context, aliases are <emphasis>local</>).
10371
- </para>
10364
+ <para>
10365
+ The optional third argument of the function is an array of namespace
10366
+ mappings. This array should be a two-dimensional <type>text</> array with
10367
+ the length of the second axis being equal to 2 (i.e., it should be an
10368
+ array of arrays, each of which consists of exactly 2 elements).
10369
+ The first element of each array entry is the namespace name (alias), the
10370
+ second the namespace URI. It is not required that aliases provided in
10371
+ this array be the same as those being used in the XML document itself (in
10372
+ other words, both in the XML document and in the <function>xpath</function>
10373
+ function context, aliases are <emphasis>local</>).
10374
+ </para>
10372
10375
10373
- <para>
10374
- Example:
10376
+ <para>
10377
+ Example:
10375
10378
<screen><![CDATA[
10376
10379
SELECT xpath('/my:a/text()', '<my:a xmlns:my="http://example.com">test</my:a>',
10377
10380
ARRAY[ARRAY['my', 'http://example.com']]);
@@ -10381,10 +10384,10 @@ SELECT xpath('/my:a/text()', '<my:a xmlns:my="http://example.com">test</my:a>',
10381
10384
{test}
10382
10385
(1 row)
10383
10386
]]></screen>
10384
- </para>
10387
+ </para>
10385
10388
10386
- <para>
10387
- To deal with default (anonymous) namespaces, do something like this:
10389
+ <para>
10390
+ To deal with default (anonymous) namespaces, do something like this:
10388
10391
<screen><![CDATA[
10389
10392
SELECT xpath('//mydefns:b/text()', '<a xmlns="http://example.com"><b>test</b></a>',
10390
10393
ARRAY[ARRAY['mydefns', 'http://example.com']]);
@@ -10394,27 +10397,31 @@ SELECT xpath('//mydefns:b/text()', '<a xmlns="http://example.com"><b>test</b></a
10394
10397
{test}
10395
10398
(1 row)
10396
10399
]]></screen>
10397
- </para>
10400
+ </para>
10401
+ </sect3>
10398
10402
10399
- <indexterm>
10400
- <primary>xpath_exists</primary>
10401
- </indexterm>
10403
+ <sect3 id="functions-xml-processing-xpath-exists">
10404
+ <title><literal>xpath_exists</literal></title>
10405
+
10406
+ <indexterm>
10407
+ <primary>xpath_exists</primary>
10408
+ </indexterm>
10402
10409
10403
10410
<synopsis>
10404
10411
<function>xpath_exists</function>(<replaceable>xpath</replaceable>, <replaceable>xml</replaceable> <optional>, <replaceable>nsarray</replaceable></optional>)
10405
10412
</synopsis>
10406
10413
10407
- <para>
10408
- The function <function>xpath_exists</function> is a specialized form
10409
- of the <function>xpath</function> function. Instead of returning the
10410
- individual XML values that satisfy the XPath, this function returns a
10411
- Boolean indicating whether the query was satisfied or not. This
10412
- function is equivalent to the standard <literal>XMLEXISTS</> predicate,
10413
- except that it also offers support for a namespace mapping argument.
10414
- </para>
10414
+ <para>
10415
+ The function <function>xpath_exists</function> is a specialized form
10416
+ of the <function>xpath</function> function. Instead of returning the
10417
+ individual XML values that satisfy the XPath, this function returns a
10418
+ Boolean indicating whether the query was satisfied or not. This
10419
+ function is equivalent to the standard <literal>XMLEXISTS</> predicate,
10420
+ except that it also offers support for a namespace mapping argument.
10421
+ </para>
10415
10422
10416
- <para>
10417
- Example:
10423
+ <para>
10424
+ Example:
10418
10425
<screen><![CDATA[
10419
10426
SELECT xpath_exists('/my:a/text()', '<my:a xmlns:my="http://example.com">test</my:a>',
10420
10427
ARRAY[ARRAY['my', 'http://example.com']]);
@@ -10424,7 +10431,8 @@ SELECT xpath_exists('/my:a/text()', '<my:a xmlns:my="http://example.com">test</m
10424
10431
t
10425
10432
(1 row)
10426
10433
]]></screen>
10427
- </para>
10434
+ </para>
10435
+ </sect3>
10428
10436
</sect2>
10429
10437
10430
10438
<sect2 id="functions-xml-mapping">
0 commit comments