xmloption

A configuration parameter determining how to convert between XML and normal strings

xmloption is a configuration parameter determining whether DOCUMENT or CONTENT is implicit when converting between XML and character string values.

xmloption was added in PostgreSQL 8.3.

Usage

xmloption can be set to one of the following values to determine how XML strings are parsed:

  • CONTENT - to process well-formed XML snippets
  • DOCUMENT - to process well-formed XML documents

xmloption can also be set with the following SQL-standard compliant command:

SET XML OPTION { DOCUMENT | CONTENT }

Default value

The default value for xmloption is: CONTENT.

Change history

Examples

Simple demonstration of xmloption settings:

postgres=# SHOW xmloption;
 xmloption
-----------
 content
(1 row)

Time: 0.299 ms
postgres=# SELECT '<foo>bar</foo><bar>foo</bar>' IS DOCUMENT;
 ?column?
----------
 f
(1 row)

postgres=# SET xmloption TO document;
SET

postgres=# SELECT '<foo>bar</foo><bar>foo</bar>' IS DOCUMENT;
ERROR:  invalid XML document
LINE 1: SELECT '<foo>bar</foo><bar>foo</bar>' IS DOCUMENT;
               ^
DETAIL:  line 1: Extra content at the end of the document
<foo>bar</foo><bar>foo</bar>
              ^

Categories

Data type, GUC configuration item, XML

See also

xmlbinary