Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 10. Generating and Retrieving XM... > Retrieving Using XMLType and SQL/XML...

Retrieving Using XMLType and SQL/XML Functions

So far, we have discussed various ways of generating XML from SQL data using the SQL/XML functions and the DBMS_XMLGEN package. In Oracle Database 10g, if you already have XML documents natively stored as XMLTypes, you can use the built-in XMLType member functions and the SQL/XML functions to retrieve and create XML. Table 10-3 summarizes the XMLType member functions and their respective XML processing functionalities.

Table 10-3. XMLType Member Functions
NameFunctionality
XMLType()

createXML()

createSchemaBasedXML()

createNonSchemaBasedXML()
Create XMLTypes from XML data stored in VARCHAR2, CLOB, or other XMLTypes.
existsNode()Checks if the XML nodes or node sets specified by XPath exist. It returns 1 if nodes or node sets are found; otherwise, it returns 0. If the XPath string is NULL or the document is empty, then a value of 0 is returned; otherwise, 1 is returned.
extract()Extracts nodes or node sets based on the XPath expression and returns an XMLType instance containing the resulting node(s).
isFragment()Checks if the XMLType is an XML document fragment or a well-formed document. It returns 1 if the XMLType is an XML document fragment or a well-formed document. Otherwise, it returns 0. Determines if the XMLType instance corresponds to a well-formed document or a fragment. Returns 1 or 0 indicating if the XMLType instance contains a fragment or a well-formed document.
getClobVal()

getNumberVal()

getStringVal()
Gets the CLOB, NUMBER, or String value in VARCHAR2, respectively, from the XMLType. You can only use getNumberVal() when the content of XMLType is numeric.
transform()Transforms the XML content in XMLType with the XSL stylesheet specified.
toObject()Casts the XMLType to other object types.
isSchemaBased()

getSchemaURL()

getRootElement()

getNamespace()
Checks the XML schema–related information of XMLType. If the XMLType is XML schema–based, isSchemaBased() returns TRUE. Then, getSchemaURL(), getRootElement(), and getNamespace() can be used to find out the registered XML schema URL, the defined root element and the namespace of the root element for the XMLType.
isSchemaValidate()

isSchemaValid()

schemaValidation()

setSchemaValidate()
Checks and updates the XML Schema validation status of XMLType. If the XMLType is valid against the XML schema, then isSchemaValidate() returns 1. The isSchemaValid() function returns the validation status of the XMLType against the supplied XML schema. To update the status of the XMLType, schemaValidation() validates the XMLType against an XML schema and updates the status to validated after the validation. If you validated the XMLTypes, you can update the status through the setSchemaValidate() procedure.



  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial