The following table describes the supported SQL XML functions.
| Function | Description |
|---|---|
DEPTH |
Returns the number of levels in the path specified by the UNDER_PATH condition using the same correlation variable. Used only with UNDER_PATH and EQUALS_PATH conditions. |
EXISTSNODE |
Determines whether traversing an XMLType document with a specified XPath expression returns any nodes. Accepts an XMLType instance and a VARCHAR2 XPath string, with an optional namespace_string for namespace mapping. Returns 1 if nodes are found, otherwise 0. |
EXTRACT (XML) |
Applies a VARCHAR2 XPath expression to an XMLType document and returns an XMLType fragment. Supports absolute paths (starting with /) or relative paths (defaulting to the root node). An optional namespace_string specifies namespace mapping when the XML uses prefixes. |
EXTRACTVALUE |
Returns a scalar value from an XMLType document based on an XPath expression. The result must be a single text node, attribute, or element with a single text child. Supports absolute paths (with /) or relative paths (defaulting to the root node). |
PATH |
Returns the relative path to the resource specified in the parent condition. Used only with UNDER_PATH and EQUALS_PATH conditions. |
SYS_DBURIGEN |
Generates a DBURIType URL for a specified column, attribute, or optionally a ROWID. The URL can be used to retrieve an XML document from the database. |
SYS_XMLAGG |
Aggregates XML documents or fragments from expr into a single XML document. Adds an enclosing ROWSET element by default. A custom format can be specified with an XMLFormat object. |
SYS_XMLGEN |
Returns an XMLType containing an XML document generated from expr. The argument can be a scalar value, a user-defined type, or an XMLType. |
XMLAGG |
Aggregates a collection of XML fragments into a single XML document, excluding any arguments that return NULL. |
XMLCAST |
Casts value_expression to the scalar SQL data type specified by datatype. The argument datatype can be NUMBER, VARCHAR2, CHAR, CLOB, BLOB, REF XMLTYPE, or any datetime type. |
XMLCDATA |
Generates a CDATA section from value_expr, which must resolve to a string. |
XMLCOLATTVAL |
Creates an XML fragment from a column and expands it so that each fragment uses the column name as the attribute name. |
XMLCOMMENT |
Generates an XML comment from value_expr, which must resolve to a string. The string cannot contain two consecutive hyphens (--). |
XMLCONCAT |
Concatenates a series of XMLType instances for each row and returns the combined result. Serves as the inverse of XMLSequence. |
XMLDIFF |
Compares two XML documents and returns an XMLType diff document that conforms to the Xdiff schema. Acts as the SQL interface to the XmlDiff C API. |
XMLELEMENT |
Creates an XML element with a specified name, optional attributes, and content arguments, and returns it as an XMLType. Similar to SYS_XMLGen, but supports attributes and does not allow formatting with XMLFormat. |
XMLEXISTS |
Checks whether an XQuery expression returns a nonempty sequence. Returns TRUE if the result is nonempty; otherwise, returns FALSE. The XQuery_string can include variables bound with the XML_passing_clause. |
XMLFOREST |
Converts each argument to XML and returns an XML fragment that concatenates the converted arguments. |
XMLISVALID |
Checks whether an XMLType instance conforms to its XML schema. Does not modify the validation status recorded for the XMLType instance. |
XMLPARSE |
Parses the evaluated result of value_expr and generates an XMLType instance. If value_expr resolves to NULL, the function returns NULL. |
XMLPATCH |
Applies changes to an XML document as specified by a patch expression and returns the patched document as an XMLType. Serves as the SQL interface to the XmlPatch C API. |
XMLPI |
Generates an XML processing instruction using identifier and optionally the evaluated result of value_expr. Processing instructions provide applications with information on how to handle all or part of an XML document. |
XMLQUERY |
Queries XML data in SQL by evaluating an XQuery expression. Accepts a string literal for the expression, an optional context item, and bind variables, and returns the result of the evaluation. |
XMLROOT |
Creates a new XML value by adding version and standalone properties to the root (prolog) of an existing XML value. Returns an error if the input already contains a prolog, or NULL if the input is NULL. |
XMLSEQUENCE |
Takes either an XMLType input and returns a varray of its top-level nodes, or a REFCURSOR input (optionally with an XMLFormat) and returns an XMLSequence of XML documents for each row in the cursor. The first form is superseded by XMLTable for more readable SQL. |
XMLSERIALIZE |
Creates a string or LOB containing the serialized contents of value_expr. |
XMLTABLE |
Maps the result of an XQuery evaluation into relational rows and columns and returns it as a virtual table that can be queried with SQL. |
XMLTRANSFORM |
Applies an XSL style sheet (XMLType) to an XMLType instance and returns the transformed result as an XMLType. |