Oracle9i XML API Reference - XDK and Oracle XML DB Release 2 (9.2) Part Number A96616-01 |
|
This chapter contains the following sections:
See Also: |
The SQLX functions supported with this release follow the SQLX standard.
XMLElement takes an element name for identifier, an optional collection of attributes for the element, and arguments that make up the element's content. It returns an instance of type XMLType. XMLElement is similar to SYS_XMLGen except that XMLElement can include attributes in the XML returned, but it does not accept formatting using the XMLFormat object.
The XMLElement function is typically nested to produce an XML document with a nested structure, as in the example in the following section.
You must specify a value for identifier, which Oracle uses as the enclosing tag. The identifier does not have to be a column name or column reference. It cannot be an expression or null.
In the XML_attributes_clause, if the value_expr is null, then no attribute is created for that value expression. The type of value_expr cannot be an object type or collection.
The objects that make up the element content follow the XMLATTRIBUTES keyword.
XMLELEMENT( elementname IN VARCHAR2, [XMLATTRIBUTES(),] value_expr, ...) RETURN XMLType XMLATTRIBUTES( value_expr [AS identifier], ...) RETURN XMLType
Parameter | Description |
---|---|
elementname |
Indicates the name of the XML element to be generated |
value_expr |
This must be a scalar value for XMLATTRIBUTES. It can be a nested XMLELEMENT call for XMLELEMENT. |
XMLForest converts each of its argument parameters to XML, and then returns an XML fragment that is the concatenation of these converted arguments.
XMLFOREST( value_expr [AS identifier], ...) RETURN XMLType
Parameter | Description |
---|---|
value_expr |
May be a scalar, object, or nested call. |
XMLColAttVal creates an XML fragment and then expands the resulting XML so that each XML fragment has the name "column" with the attribute "name". You can use the AS c_alias clause to change the value of the name attribute to something other than the column name.
You must specify a value for value_expr. If value_expr is null, then no element is returned.
Restriction: You cannot specify an object type column for value_expr.
XMLCOLATTVAL( value_expr [AS identifier], ...) RETURN XMLType
Parameter | Description |
---|---|
value_expr |
May be a scalar, object, or nested call. |
The EXTRACTVALUE function takes as arguments an XMLType instance and an XPath expression and returns a scalar value of the resultant node. The result must be a single node and be either a text node, attribute, or element. If the result is an element, the element must have a single text node as its child, and it is this value that the function returns. If the specified XPath points to a node with more than one child, or if the node pointed to has a non-text node child, Oracle returns an error.
For documents based on XML schemas, if Oracle can infer the type of the return value, then a scalar value of the appropriate type is returned. Otherwise, the result is of type VARCHAR2. For documents that are not based on XML schemas, the return type is always VARCHAR2.
EXTRACTVALUE( instance IN XMLType, xpath IN VARCHAR2, [namespace IN VARCHAR2]) RETURN value
Parameter | Description |
---|---|
instance |
The XMLType to extract the data from. |
xpath |
XPath expression as a string |
namespace |
Optional argument specifying namespace declarations. |
XMLTransform takes as arguments an XMLType instance and an XSL style sheet, which is itself a form of XMLType instance. It applies the style sheet to the instance and returns an XMLType.
This function is useful for organizing data according to a style sheet as you are retrieving it from the database.
XMLTRANSFORM( instance IN XMLType, xslt IN XMLType) RETURN XMLType
Parameter | Description |
---|---|
instance |
The XMLType instance to be transformed. |
xslt |
The XSLT document to transform the instance. |
XMLSequence has two forms:
Because XMLSequence returns a collection of XMLType, you can use this function in a TABLE clause to unnest the collection values into multiple rows, which can in turn be further processed in the SQL query.
XMLSEQUENCE( { input IN XMLType | input IN SYS_REFCURSOR, [format IN XMLFormat] }) RETURN XMLType
Parameter | Description |
---|---|
input |
The data to be split up. |
format |
The optional XMLFormat to be used to format the output from the cursor. |
XMLConcat takes as input a series of XMLType instances, concatenates the series of elements for each row, and returns the concatenated series. XMLConcat is the inverse of XMLSequence.
Null expressions are dropped from the result. If all the value expressions are null, then the function returns null.
The options are described in the following table.
Parameter | Description |
---|---|
data |
The XMLSequenceType to be concatenated together. |
arg1, arg2, ... |
The XMLType arguments to be concatenated together. |
UPDATEXML takes as arguments an XMLType instance and an XPath-value pair, and returns an XMLType instance with the updated value. If XPath_string is an XML element, then the corresponding value_expr must be an XMLType instance. If XPath_string is an attribute or text node, then the value_expr can be any scalar datatype. The datatypes of the target of XPath_string and the value_expr must match.
If you update an XML element to null, Oracle removes the attributes and children of the element, and the element becomes empty. If you update the text node of an element to null, Oracle removes the text value of the element, and the element itself remains but is empty.
In most cases, this function materializes an XML document in memory and updates the value. However, UPDATEXML is optimized for UPDATE statements on object-relational columns so that the function updates the value directly in the column. This optimization requires the following conditions:
UPDATEXML( instance IN XMLType, [xpath IN VARCHAR2, value_expr)], ..., [namespace IN VARCHAR2] ) RETURN XMLType
|
Copyright © 2001, 2002 Oracle Corporation. All Rights Reserved. |
|