@@ -10328,50 +10328,53 @@ SELECT xml_is_well_formed_document('<pg:foo xmlns:pg="http://postgresql.org/stuf
1032810328 <sect2 id="functions-xml-processing">
1032910329 <title>Processing XML</title>
1033010330
10331- <indexterm>
10332- <primary>XPath</primary>
10333- </indexterm>
10334-
1033510331 <para>
1033610332 To process values of data type <type>xml</type>, PostgreSQL offers
1033710333 the functions <function>xpath</function> and
1033810334 <function>xpath_exists</function>, which evaluate XPath 1.0
1033910335 expressions.
1034010336 </para>
1034110337
10338+ <sect3 id="functions-xml-processing-xpath">
10339+ <title><literal>xpath</literal></title>
10340+
10341+ <indexterm>
10342+ <primary>XPath</primary>
10343+ </indexterm>
10344+
1034210345<synopsis>
1034310346<function>xpath</function>(<replaceable>xpath</replaceable>, <replaceable>xml</replaceable> <optional>, <replaceable>nsarray</replaceable></optional>)
1034410347</synopsis>
1034510348
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>
1035510358
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>
1036010363
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>
1037210375
10373- <para>
10374- Example:
10376+ <para>
10377+ Example:
1037510378<screen><![CDATA[
1037610379SELECT xpath('/my:a/text()', '<my:a xmlns:my="http://example.com">test</my:a>',
1037710380 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>',
1038110384 {test}
1038210385(1 row)
1038310386]]></screen>
10384- </para>
10387+ </para>
1038510388
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:
1038810391<screen><![CDATA[
1038910392SELECT xpath('//mydefns:b/text()', '<a xmlns="http://example.com"><b>test</b></a>',
1039010393 ARRAY[ARRAY['mydefns', 'http://example.com']]);
@@ -10394,27 +10397,31 @@ SELECT xpath('//mydefns:b/text()', '<a xmlns="http://example.com"><b>test</b></a
1039410397 {test}
1039510398(1 row)
1039610399]]></screen>
10397- </para>
10400+ </para>
10401+ </sect3>
1039810402
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>
1040210409
1040310410<synopsis>
1040410411<function>xpath_exists</function>(<replaceable>xpath</replaceable>, <replaceable>xml</replaceable> <optional>, <replaceable>nsarray</replaceable></optional>)
1040510412</synopsis>
1040610413
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>
1041510422
10416- <para>
10417- Example:
10423+ <para>
10424+ Example:
1041810425<screen><![CDATA[
1041910426SELECT xpath_exists('/my:a/text()', '<my:a xmlns:my="http://example.com">test</my:a>',
1042010427 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
1042410431 t
1042510432(1 row)
1042610433]]></screen>
10427- </para>
10434+ </para>
10435+ </sect3>
1042810436 </sect2>
1042910437
1043010438 <sect2 id="functions-xml-mapping">
0 commit comments