XMLSERIALIZE
Syntax
Purpose
XMLSerialize creates a string or LOB containing the contents of value_expr.
-
If you specify
DOCUMENT, then thevalue_exprmust be a valid XML document. -
If you specify
CONTENT, then thevalue_exprneed not be a singly rooted XML document. However it must be valid XML content. -
The
datatypespecified can be a string type (VARCHAR2orVARCHAR, but notNVARCHAR2),BLOB, orCLOB. The default isCLOB. -
If
datatypeisBLOB, then you can specify theENCODINGclause to use the specified encoding in the prolog. Thexml_encoding_specis an XML encoding declaration (encoding="..."). -
Specify the
VERSIONclause to use the version you provide asstring_literalin the XML declaration (<?xml version="..." ...?>). -
Specify
NOINDENTto strip all insignificant whitespace from the output. SpecifyINDENT SIZE =N, whereNis a whole number, for output that is pretty-printed using a relative indentation ofNspaces. IfNis0, 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. IfINDENTis present without aSIZEspecification, then 2-space indenting is used. If you omit this clause, then the behavior (pretty-printing or not) is indeterminate. -
HIDE DEFAULTSandSHOW DEFAULTSapply only to XML schema-based data. If you specifySHOW DEFAULTSand 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 DEFAULTSis 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>
