|
1 |
| -<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.379 2007/05/07 07:53:26 petere Exp $ --> |
| 1 | +<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.380 2007/05/21 17:10:28 petere Exp $ --> |
2 | 2 |
|
3 | 3 | <chapter id="functions">
|
4 | 4 | <title>Functions and Operators</title>
|
@@ -7512,7 +7512,7 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
|
7512 | 7512 | type. The function-like expressions <function>xmlparse</function>
|
7513 | 7513 | and <function>xmlserialize</function> for converting to and from
|
7514 | 7514 | type <type>xml</type> are not repeated here. Use of many of these
|
7515 |
| - <type>xml</type> functions requires the installation to have been built |
| 7515 | + functions requires the installation to have been built |
7516 | 7516 | with <command>configure --with-libxml</>.
|
7517 | 7517 | </para>
|
7518 | 7518 |
|
@@ -7848,6 +7848,51 @@ SELECT xmlroot(xmlparse(document '<?xml version="1.1"?><content>abc</content>'),
|
7848 | 7848 | </sect3>
|
7849 | 7849 | </sect2>
|
7850 | 7850 |
|
| 7851 | + <sect2 id="functions-xml-processing"> |
| 7852 | + <title>Processing XML</title> |
| 7853 | + |
| 7854 | + <indexterm> |
| 7855 | + <primary>XPath</primary> |
| 7856 | + </indexterm> |
| 7857 | + |
| 7858 | + <para> |
| 7859 | + To process values of data type <type>xml</type>, PostgreSQL offers |
| 7860 | + the function <function>xpath</function>, which evaluates XPath 1.0 |
| 7861 | + expressions. |
| 7862 | + </para> |
| 7863 | + |
| 7864 | +<synopsis> |
| 7865 | +<function>xpath</function>(<replaceable>xpath</replaceable>, <replaceable>xml</replaceable><optional>, <replaceable>nsarray</replaceable></optional>) |
| 7866 | +</synopsis> |
| 7867 | + |
| 7868 | + <para> |
| 7869 | + The function <function>xpath</function> evaluates the XPath |
| 7870 | + expression <replaceable>xpath</replaceable> against the XML value |
| 7871 | + <replaceable>xml</replaceable>. It returns an array of XML values |
| 7872 | + corresponding to the node set produced by the XPath expression. |
| 7873 | + </para> |
| 7874 | + |
| 7875 | + <para> |
| 7876 | + The third argument of the function is an array of namespace |
| 7877 | + mappings. This array should be a two-dimensional array with the |
| 7878 | + length of the second axis being equal to 2 (i.e., it should be an |
| 7879 | + array of arrays, each of which consists of exactly 2 elements). |
| 7880 | + The first element of each array entry is the namespace name, the |
| 7881 | + second the namespace URI. |
| 7882 | + </para> |
| 7883 | + |
| 7884 | + <para> |
| 7885 | + Example: |
| 7886 | +<screen><![CDATA[ |
| 7887 | +SELECT xpath('/my:a/text()', '<my:a xmlns:my="http://example.com">test</my:a>', ARRAY[ARRAY['my', 'http://example.com']]); |
| 7888 | + xpath |
| 7889 | +-------- |
| 7890 | + {test} |
| 7891 | +(1 row) |
| 7892 | +]]></screen> |
| 7893 | + </para> |
| 7894 | + </sect2> |
| 7895 | + |
7851 | 7896 | <sect2 id="functions-xml-mapping">
|
7852 | 7897 | <title>Mapping Tables to XML</title>
|
7853 | 7898 |
|
@@ -8097,75 +8142,6 @@ table2-mapping
|
8097 | 8142 | ]]></programlisting>
|
8098 | 8143 | </figure>
|
8099 | 8144 | </sect2>
|
8100 |
| - |
8101 |
| - <sect2> |
8102 |
| - <title>Processing XML</title> |
8103 |
| - |
8104 |
| - <para> |
8105 |
| - <acronym>XML</> support is not just the existence of an |
8106 |
| - <type>xml</type> data type, but a variety of features supported by |
8107 |
| - a database system. These capabilities include import/export, |
8108 |
| - indexing, searching, transforming, and <acronym>XML</> to |
8109 |
| - <acronym>SQL</> mapping. <productname>PostgreSQL</> supports some |
8110 |
| - but not all of these <acronym>XML</> capabilities. For an |
8111 |
| - overview of <acronym>XML</> use in databases, see <ulink |
8112 |
| - url="http://www.rpbourret.com/xml/XMLAndDatabases.htm"></>. |
8113 |
| - </para> |
8114 |
| - |
8115 |
| - <variablelist> |
8116 |
| - <varlistentry> |
8117 |
| - <term>Indexing</term> |
8118 |
| - <listitem> |
8119 |
| - |
8120 |
| - <para> |
8121 |
| - <filename>contrib/xml2/</> functions can be used in expression |
8122 |
| - indexes to index specific <acronym>XML</> fields. To index the |
8123 |
| - full contents of <acronym>XML</> documents, the full-text |
8124 |
| - indexing tool <filename>contrib/tsearch2/</> can be used. Of |
8125 |
| - course, Tsearch2 indexes have no <acronym>XML</> awareness so |
8126 |
| - additional <filename>contrib/xml2/</> checks should be added to |
8127 |
| - queries. |
8128 |
| - </para> |
8129 |
| - </listitem> |
8130 |
| - </varlistentry> |
8131 |
| - |
8132 |
| - <varlistentry> |
8133 |
| - <term>Searching</term> |
8134 |
| - <listitem> |
8135 |
| - |
8136 |
| - <para> |
8137 |
| - XPath searches are implemented using <filename>contrib/xml2/</>. |
8138 |
| - It processes <acronym>XML</> text documents and returns results |
8139 |
| - based on the requested query. |
8140 |
| - </para> |
8141 |
| - </listitem> |
8142 |
| - </varlistentry> |
8143 |
| - |
8144 |
| - <varlistentry> |
8145 |
| - <term>Transforming</term> |
8146 |
| - <listitem> |
8147 |
| - |
8148 |
| - <para> |
8149 |
| - <filename>contrib/xml2/</> supports <acronym>XSLT</> (Extensible |
8150 |
| - Stylesheet Language Transformation). |
8151 |
| - </para> |
8152 |
| - </listitem> |
8153 |
| - </varlistentry> |
8154 |
| - |
8155 |
| - <varlistentry> |
8156 |
| - <term>XML to SQL Mapping</term> |
8157 |
| - <listitem> |
8158 |
| - |
8159 |
| - <para> |
8160 |
| - This involves converting <acronym>XML</> data to and from |
8161 |
| - relational structures. <productname>PostgreSQL</> has no |
8162 |
| - internal support for such mapping, and relies on external tools |
8163 |
| - to do such conversions. |
8164 |
| - </para> |
8165 |
| - </listitem> |
8166 |
| - </varlistentry> |
8167 |
| - </variablelist> |
8168 |
| - </sect2> |
8169 | 8145 | </sect1>
|
8170 | 8146 |
|
8171 | 8147 |
|
|
0 commit comments