1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Various fixes in the logic of XML functions:

- Add new SQL command SET XML OPTION (also available via regular GUC) to
  control the DOCUMENT vs. CONTENT option in implicit parsing and
  serialization operations.

- Subtle corrections in the handling of the standalone property in
  xmlroot().

- Allow xmlroot() to work on content fragments.

- Subtle corrections in the handling of the version property in
  xmlconcat().

- Code refactoring for producing XML declarations.
This commit is contained in:
Peter Eisentraut
2007-01-25 11:53:52 +00:00
parent 9597446d11
commit 22bd156ff0
13 changed files with 329 additions and 121 deletions

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.105 2007/01/25 04:35:10 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.106 2007/01/25 11:53:50 petere Exp $ -->
<chapter Id="runtime-config">
<title>Server Configuration</title>
@ -3558,6 +3558,38 @@ SELECT * FROM parent WHERE key = 2400;
</listitem>
</varlistentry>
<varlistentry id="guc-xmloption" xreflabel="xmloption">
<term><varname>xmloption</varname> (<type>string</type>)</term>
<indexterm>
<primary><varname>xmloption</> configuration parameter</primary>
</indexterm>
<indexterm>
<primary><varname>SET XML OPTION</></primary>
</indexterm>
<indexterm>
<primary><varname>XML option</></primary>
</indexterm>
<listitem>
<para>
Sets whether <literal>DOCUMENT</literal> or
<literal>CONTENT</literal> is implicit when converting between
XML and character string values. See <xref
linkend="datatype-xml"> for a description of this. Valid
values are <literal>DOCUMENT</literal> and
<literal>CONTENT</literal>. The default is
<literal>CONTENT</literal>.
</para>
<para>
According to the SQL standard, the command to set this option is
<synopsis>
SET XML OPTION { DOCUMENT | CONTENT };
</synopsis>
This syntax is also available in PostgreSQL.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2 id="runtime-config-client-format">

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.185 2007/01/18 13:59:11 petere Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.186 2007/01/25 11:53:50 petere Exp $ -->
<chapter id="datatype">
<title id="datatype-title">Data Types</title>
@ -3474,6 +3474,24 @@ XMLSERIALIZE ( { DOCUMENT | CONTENT } <replaceable>value</replaceable> AS <repla
you to simply cast the value.
</para>
<para>
When character string values are cast to or from type
<type>xml</type> without going through <type>XMLPARSE</type> or
<type>XMLSERIALIZE</type>, respectively, the choice of
<literal>DOCUMENT</literal> versus <literal>CONTENT</literal> is
determined by the <quote>XML option</quote> session configuration
parameter, which can be set using the standard command
<synopsis>
SET XML OPTION { DOCUMENT | CONTENT };
</synopsis>
or the more PostgreSQL-like syntax
<synopsis>
SET xmloption TO { DOCUMENT | CONTENT };
</synopsis>
The default is <literal>CONTENT</literal>, so all forms of XML
data are allowed.
</para>
<para>
Care must be taken when dealing with multiple character encodings
on the client, server, and in the XML data passed through them.