Start of change

SQL/XML publishing functions for constructing XML values

You can construct XML values, which do not necessarily have to be well-formed XML documents, by combining those publishing functions that correspond to the components you want in the resulting XML value. The functions must be specified in the order that you want the results to appear.

Values constructed using the SQL/XML publishing functions are returned as XML. Depending on what you want to do with the XML value, you might need to explicitly serialize the value to convert it to another SQL data type. Refer to the documentation on XML serialization for details.

The following SQL/XML publishing functions can be used to construct XML values.

XMLAGG aggregate function
Returns an XML sequence containing an item for each non-null value in a set of XML values.
XMLATTRIBUTES scalar function
Constructs XML attributes from the arguments. This function can be used only as an argument of the XMLELEMENT function.
XMLCOMMENT scalar function
Returns an XML value with the input argument as the content.
XMLCONCAT scalar function
Returns a sequence containing the concatenation of a variable number of XML input arguments.
XMLDOCUMENT scalar function
Returns an XML value that is a well-formed XML document. Every XML value that is stored in a DB2® table must be a document. This function forms an XML document from the XML value.
XMLELEMENT scalar function
Returns an XML value that is an XML element. Every XML value that is stored in a DB2 table must be a document. The XMLELEMENT function does not create a document, only an element. The stored XML value must be a document formed by the XMLDOCUMENT function.
XMLFOREST scalar function
Returns an XML value that is a sequence of XML elements.
XMLGROUP aggregate function
Returns a single top-level element to represent a table or the result of a query. By default each row in the result set is mapped to a row subelement and each input expression is mapped to a subelement of the row subelement. Optionally, each row in the result can be mapped to a row subelement and each input expression to be mapped to an attribute of the row subelement.
XMLNAMESPACES declaration
Constructs namespace declarations from the arguments. This declaration can be used only as an argument of the XMLELEMENT and XMLFOREST functions.
XMLPI scalar function
Returns an XML value with a single processing instruction.
XMLROW scalar function
Returns a sequence of row elements to represent a table or the result of a query. By default each input expression is transformed into a subelement of a row element. Optionally, each input expression can be transformed into an attribute of a row element.
XMLTEXT scalar function
Returns an XML value that contains the value of the input argument.
XSLTRANSFORM scalar function
Converts XML data into other formats, including other XML schemas.
End of change