+SELECT xmlforest('abc' AS foo, 123 AS bar);
+
+ xmlforest
+------------------------------
+ abc123
+
+
+SELECT xmlforest(table_name, column_name) FROM information_schema.columns WHERE table_schema = 'pg_catalog';
+
+ xmlforest
+-------------------------------------------------------------------------------------------
+ ...
+]]>
+
+ As seen in the second example, the element name can be omitted if
+ the content value is a column reference, in which case the column
+ name is used by default. Otherwise, a name must be specified.
+
+
+ Element names that are not valid XML names are escaped as shown
+ for xmlelement above. Similarly, content
+ data is escaped to make valid XML content, unless it is already
+ of type xml.
+
+
+ Note that XML forests are not valid XML documents if they consist
+ of more than one element. So it might be useful to wrap
+ xmlforest expressions in
+ xmlelement.
- >
+ >
- 2>
+ 3>
xmlpi
- Creates an XML processing instruction.
+ The xmlpi expression creates an XML
+ processing instruction. The content, if present, must not
+ contain the character sequence ?<.
+
+
+ Example:
+
+SELECT xmlpi(name php, 'echo "hello world";');
+
+ xmlpi
+-----------------------------
+
+]]>
- >
+ >
- 2>
+ 3>
xmlroot
- xmlroot(xml, version text , standalone yes|no|no value)
+ xmlroot(xml, version text|no value , standalone yes|no|no value)
- Creates the root node of an XML document.
+ The xmlroot expression alters the properties
+ of the root node of an XML value. If a version is specified,
+ this replaces the value in the version declaration, if a
+ standalone value is specified, this replaces the value in the
+ standalone declaration.
+
+
+
+SELECT xmlroot(xmlparse(document 'abc'), version '1.0', standalone yes);
+
+ xmlroot
+----------------------------------------
+
+ abc
+]]>
+
+
+
+
+
XML Predicates
+
+
+
+
+
+xml IS DOCUMENT
+
+
+ The expression IS DOCUMENT returns true if the
+ argument XML value is a proper XML document, false if it is not
+ (that is, it is a content fragment), or null if the argument is
+ null. See about the difference
+ between documents and content fragments.
+
+
+
+
+
Processing XML
+
+
XML> support is not just the existence of an
+ xml data type, but a variety of features supported by
+ a database system. These capabilities include import/export,
+ indexing, searching, transforming, and
XML> to
+
SQL> mapping. PostgreSQL> supports some
+ but not all of these
XML> capabilities. For an
+ overview of
XML> use in databases, see
+ url="http://www.rpbourret.com/xml/XMLAndDatabases.htm">>.
+
+
+
+
+ Import/Export
+
+
+ There is no facility for mapping
XML> to relational
+ tables. An external tool must be used for this. One simple way
+ to export
XML> is to use psql> in
+
HTML> mode (\pset format html>), and
+ convert the
XHTML> output to XML using an external
+ tool.
+
+
+
+
+
+ Indexing
+
+
+ contrib/xml2/> functions can be used in expression
+ indexes to index specific
XML> fields. To index the
+ full contents of
XML> documents, the full-text
+ indexing tool contrib/tsearch2/> can be used. Of
+ course, Tsearch2 indexes have no
XML> awareness so
+ additional contrib/xml2/> checks should be added to
+ queries.
+
+
+
+
+
+ Searching
+
+
+ XPath searches are implemented using contrib/xml2/>.
+ It processes
XML> text documents and returns results
+ based on the requested query.
+
+
+
+
+
+ Transforming
+
+
+
contrib/xml2/> supports XSLT> (Extensible
+ Stylesheet Language Transformation).
+
+
+
+
+
+ XML to SQL Mapping
+
+
+ This involves converting
XML> data to and from
+ relational structures.
PostgreSQL> has no
+ internal support for such mapping, and relies on external tools
+ to do such conversions.
+
+
+
+
-