XMLSERIALIZE
Syntax
Purpose
XMLSerialize
creates a string or LOB containing the contents of value_expr
.
-
If you specify
DOCUMENT
, then thevalue_expr
must be a valid XML document. -
If you specify
CONTENT
, then thevalue_expr
need not be a singly rooted XML document. However it must be valid XML content. -
The
datatype
specified can be a string type (VARCHAR2
orVARCHAR
, but notNVARCHAR2
),BLOB
, orCLOB
. The default isCLOB
. -
If
datatype
isBLOB
, then you can specify theENCODING
clause to use the specified encoding in the prolog. Thexml_encoding_spec
is an XML encoding declaration (encoding="..."
). -
Specify the
VERSION
clause to use the version you provide asstring_literal
in the XML declaration (<?xml version="..." ...?>
). -
Specify
NO
INDENT
to strip all insignificant whitespace from the output. SpecifyINDENT SIZE =
N
, whereN
is a whole number, for output that is pretty-printed using a relative indentation ofN
spaces. IfN
is0
, then pretty-printing inserts a newline character after each element, placing each element on a line by itself, but omitting all other insignificant whitespace in the output. IfINDENT
is present without aSIZE
specification, then 2-space indenting is used. If you omit this clause, then the behavior (pretty-printing or not) is indeterminate. -
HIDE DEFAULTS
andSHOW DEFAULTS
apply only to XML schema-based data. If you specifySHOW DEFAULTS
and the input data is missing any optional elements or attributes for which the XML schema defines default values, then those elements or attributes are included in the output with their default values. If you specifyHIDE DEFAULTS
, then no such elements or attributes are included in the output.HIDE DEFAULTS
is the default behavior.
See Also:
-
Oracle XML DB Developer's Guide for more information on this function
-
Appendix C in Oracle Database Globalization Support Guide for the collation derivation rules, which define the collation assigned to the character return value of
XMLSERIALIZE
Examples
The following statement uses the DUAL
table to illustrate the syntax of XMLSerialize
:
SELECT XMLSERIALIZE(CONTENT XMLTYPE('<Owner>Grandco</Owner>')) AS xmlserialize_doc FROM DUAL; XMLSERIALIZE_DOC ---------------- <Owner>Grandco</Owner>