Skip Headers

Oracle® XML DB Developer's Guide
10g Release 1 (10.1)

Part Number B10790-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

F SQL and PL/SQL APIs: Quick Reference

This appendix provides a summary of the Oracle XML DB SQL and PL/SQL application program interfaces (APIs).

This appendix contains these topics:

XMLType API

XMLType is a system-defined opaque type for handling XML data. XMLType has predefined member functions to extract XML nodes and fragments. You can create columns of XMLType and insert XML documents into them. You can also generate XML documents as XMLType instances dynamically using SQL functions, SYS_XMLGEN and SYS_XMLAGG, the PL/SQL package DBMS_XMLGEN, and the SQLX functions.

Table F-1 lists the XMLType API functions.

Table F-1 XMLType API

Function Description
XMLType()
constructor function XMLType(
xmlData IN clob, schema IN varchar2 :=
 NULL, validated IN number := 0,
 wellformed IN Number := 0)
 return self as result
constructor function XMLType(
xmlData IN varchar2, schema IN varchar2
 := NULL, validated IN number := 0,
 wellformed IN number := 0)
 return self as result
constructor function XMLType (
xmlData IN "<ADT_1>", schema IN varchar2
 := NULL, element IN varchar2 := NULL,
 validated IN number := 0)
return self as result
constructor function XMLType(
xmlData IN SYS_REFCURSOR, 
schema in varchar2 :=
 NULL, element in varchar2 := NULL,
 validated in number := 0)
return self as result
Constructor that constructs an instance of the XMLType datatype. The constructor can take in the XML as a CLOB, VARCHAR2 or take in a object type.

Parameters:

xmlData - data in the form of a CLOB, REF cursor, VARCHAR2 or object type.

schema - optional schema URL used to make the input conform to the given schema.

validated - flag to indicate that the instance is valid according to the given XMLSchema. (default 0)

wellformed - flag to indicate that the input is wellformed. If set, then the database would not do well formed check on the input instance. (default 0)

element - optional element name in the case of the ADT_1 or REF CURSOR constructors. (default null)

constructor function XMLType (
xmlData IN BLOB,   csid IN number,
schema IN varchar2 := NULL, 
validated IN number := 0, 
wellformed IN number := 0) 
return self as result deterministic;

constructor function XMLType (
xmlData IN BFILE, csid IN number, 
schema IN varchar2 := NULL, 
validated IN number := 0, 
wellformed IN number := 0) 
return self as result deterministic;
Creates an XMLType instance given a BLOB or a BFILE with the specified character set id.

Parameters: xmlData (IN) - input data to generate the XMLType instance.

csid (IN) - Character set id in which the input data is encoded. If zero is specified then the input encoding is auto-detected based on the character detection rule defined in the W3C XML Recommendation.

schema (IN) - Optional schema URL to be used to make the input conform to the given schema.

validated (IN) - Flag to indicate that the instance is valid according to the given XMLSchema. (default 0)

wellformed (IN) - Flag to indicate that the input is wellformed. If set, then the database would not do well formed check on the input instance. (default 0)

createXML()
STATIC FUNCTION createXML(
xmlval IN varchar2)
 RETURN XMLType deterministic
STATIC FUNCTION createXML(
xmlval IN clob) RETURN XMLType
STATIC FUNCTION createXML (
xmlData IN clob, schema IN varchar2,
validated IN number := 0, 
wellformed IN number := 0 )
RETURN XMLType deterministic
STATIC FUNCTION createXML (
xmlData IN varchar2, schema IN varchar2,
validated IN number := 0,
wellformed IN number := 0)
RETURN XMLType deterministic
STATIC FUNCTION createXML (
xmlData IN "<ADT_1>", schema IN varchar2
 := NULL, element IN varchar2 := NULL,
validated IN NUMBER := 0)
RETURN XMLType deterministic
STATIC FUNCTION createXML (
xmlData IN SYS_REFCURSOR, 
schema in varchar2 := NULL, 
element in varchar2 := NULL, 
validated in number := 0)
RETURN XMLType deterministic
STATIC FUNCTION createXML (
xmlData IN blob, csid IN number, 
schema IN varchar2, validated IN number
 := 0, wellformed IN number := 0)
RETURN sys.XMLType
STATIC FUNCTION createXML (
xmlData IN bfile, csid IN number,
schema IN varchar2, validated IN number
 := 0, wellformed IN number := 0)
RETURN sys.XMLType
Static function for creating and returning an XMLType instance. The string and CLOB parameters used to pass in the date must contain well-formed and valid XML documents. The options are described in the following table.

Parameters:

xmlData - Actual data in the form of a CLOB, BLOB, BFILE, REF cursor, VARCHAR2 or object type.

schema - Optional Schema URL to be used to make the input conform to the given schema.

validated - Flag to indicate that the instance is valid according to the given XMLSchema. (default 0)

wellformed - Flag to indicate that the input is wellformed. If set, then the database would not do well formed check on the input instance. (default 0)

element - Optional element name in the case of the ADT_1 or REF CURSOR constructors. (default NULL)

csid - Specifies the character set id of the input xmlData if it is nonzero; otherwise, the character encoding of the input is determined based on the character detection rule defined in the W3C XML Recommendation.

existsNode()
MEMBER FUNCTION existsNode(
xpath IN varchar2)
RETURN number deterministic
MEMBER FUNCTION existsNode(
xpath in varchar2, nsmap in varchar2)
RETURN number deterministic;
Takes an XMLType instance and a XPath and returns 1 or 0 indicating if applying the XPath returns a non-empty set of nodes. If the XPath string is NULL or the document is empty, then a value of 0 is returned, otherwise returns 1.

Parameters:

xpath - XPath expression to test.

nsmap - Optional namespace mapping.

extract()
MEMBER FUNCTION extract(
xpath IN varchar2)
RETURN XMLType deterministic;
MEMBER FUNCTION extract(
xpath IN varchar2, nsmap IN varchar2)
RETURN XMLType deterministic;
Extracts an XMLType fragment and returns an XMLType instance containing the result node(s). If the XPath does not result in any nodes, then it returns NULL.

Parameters:

xpath - XPath expression to apply.

nsmap - Optional prefix to namespace mapping information.

isFragment()
MEMBER FUNCTION isFragment()
RETURN number deterministic;
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. Returns 1 or 0 indicating if the XMLType instance contains a fragment or a well-formed document..
getClobVal()
MEMBER FUNCTION getClobVal()
RETURN CLOB deterministic;
Returns a CLOB containing the serialized XML representation; if the return is a temporary CLOB, then it must be freed after use.
getBlobVal()
MEMBER FUNCTION getBlobVal(
csid IN number)
RETURN BLOB deterministic;
Returns a BLOB value of an XMLType instance in the specified character set.

Parameter csid (IN) - The character set id which the returned BLOB will be encoded in. It must be greater than zero and a valid Oracle character set id otherwise an error is returned.

getNumberVal()
MEMBER FUNCTION getNumberVal()
RETURN number deterministic;
Returns a numeric value, formatted from the text value pointed to by the XMLType instance. The XMLType must point to a valid text node that contains a numerical value.
getStringVal()
MEMBER FUNCTION getStringVal()
RETURN varchar2 deterministic;
Returns the document as a string containing the serialized XML representation, or for text nodes, the text itself. If the XML document is bigger than the maximum size of the VARCHAR2, 4000, then an error is raised at run time.
transform()
MEMBER FUNCTION transform(
xsl IN XMLType, parammap in varchar2 :=
 NULL) RETURN XMLType deterministic
Transforms XML data using the XSL style-sheet argument and the top-level parameters passed as a string of name=value pairs. If any argument other than the parammap is NULL, then a NULL is returned.

Parameter

xsl - XSLT style sheet describing the transformation

parammap - top level parameters to the XSL - string of name=value pairs

toObject()
MEMBER PROCEDURE toObject(
SELF in XMLType, object OUT "<ADT_1>",
schema in varchar2 := NULL, 
element in varchar2 := NULL)
Converts XML data into an instance of a user defined type, using the optional schema and top-level element arguments.

Parameters:

SELF - instance to be converted. Implicit if used as a member procedure.

object - converted object instance of the required type may be passed in to this function.

schema - schema URL. Mapping of the XMLType instance to the converted object instance can be specified using a schema.

element - top-level element name. This specifies the top-level element name in the XMLSchema document to map the XMLType instance.

isSchemaBased()
MEMBER FUNCTION isSchemaBased
 return number deterministic
Determines if the XMLType instance is schema-based. Returns 1 or 0 depending on whether the XMLType instance is schema-based or not.
getSchemaURL()
MEMBER FUNCTION getSchemaURL
 return varchar2 deterministic
Returns the XML schema URL corresponding to the XMLType instance, if the XMLType instance is a schema-based document. Otherwise returns NULL.
getRootElement()
MEMBER FUNCTION getRootElement
 return varchar2 deterministic
Gets the root element of the XMLType instance. Returns NULL if the instance is a fragment.
createSchemaBasedXML()
MEMBER FUNCTION createSchemaBasedXML(
schema IN varchar2 := NULL)
return sys.XMLType deterministic
Creates a schema-based XMLType instance from a non-schema-based XML and a schema URL.

Parameter:

schema - schema URL If NULL, then the XMLType instance must contain a schema URL.

createNonSchemaBasedXML()
MEMBER FUNCTION createNonSchemaBasedXML
return XMLType deterministic
Creates a non-schema-based XML document from an XML schema-based instance.
getNamespace()
MEMBER FUNCTION getNamespace
return varchar2 deterministic
Returns the namespace of the top level element in the instance. NULL if the input is a fragment or is a non-schema-based instance.
schemaValidate()
MEMBER PROCEDURE schemaValidate
Validates the XML instance against its schema if it has not already validated. For non-schema based documents an error is raised. If validation fails then an error is raised; else, the document status is changed to validated.
isSchemaValidated()
MEMBER FUNCTION isSchemaValidated
return NUMBER deterministic
Returns the validation status of the XMLType instance if it has been validated against its schema. Returns 1 if validated against the schema, 0 otherwise.
setSchemaValidated()
MEMBER PROCEDURE setSchemaValidated(flag IN BINARY_INTEGER := 1)
Sets the VALIDATION state of the input XML instance to avoid schema validation.

Parameter: flag - 0 = NOT VALIDATED; 1 = VALIDATED; Default value is 1.

isSchemaValid()
member function isSchemaValid(
schurl IN VARCHAR2 := NULL, 
elem IN VARCHAR2 := NULL)
return NUMBER deterministic
Checks if the input instance conforms to a specified schema. Does not change validation status of the XML instance. If an XML schema URL is not specified and the XML document is schema-based, then conformance is checked against the XML schema of the XMLType instance.

Parameter:

schurl - URL of the XML Schema against which to check conformance.

elem - Element of a specified schema, against which to validate. Useful when you have an XML Schema that defines more than one top level element, and you must check conformance against a specific elements.


PL/SQL DOM API for XMLType (DBMS_XMLDOM)

Table F-2 lists the PL/SQL Document Object Model (DOM) API for XMLType (DBMS_XMLDOM) methods supported in release 2 (9.2.0.1). These are grouped according to the W3C DOM Recommendation. The following DBMS_XMLDOM methods are not supported in release 2 (9.2.0.2):

Table F-3 lists additional methods supported in release 2 (9.2.0.2).

Table F-2 Summary of Release 2 (9.2.0.1) DBMS_XMLDOM Methods

Group/Method Description
Node methods --
isNull()
Tests if the node is NULL.
makeAttr()
Casts the node to an attribute.
makeCDataSection()
Casts the node to a CDataSection.
makeCharacterData()
Casts the node to CharacterData.
makeComment()
Casts the node to a Comment.
makeDocumentFragment()
Casts the node to a DocumentFragment.
makeDocumentType()
Casts the node to a Document Type.
makeElement()
Casts the node to an element.
makeEntity()
Casts the node to an Entity.
makeEntityReference()
Casts the node to an EntityReference.
makeNotation()
Casts the node to a Notation.
makeProcessingInstruction()
Casts the node to a DOMProcessingInstruction.
makeText()
Casts the node to a DOMText.
makeDocument()
Casts the node to a DOMDocument.
writeToFile()
Writes the contents of the node to a file.
writeToBuffer()
Writes the contents of the node to a buffer.
writeToClob()
Writes the contents of the node to a CLOB.
getNodeName()
Retrieves the Name of the Node.
getNodeValue()
Retrieves the Value of the Node.
setNodeValue()
Sets the Value of the Node.
getNodeType()
Retrieves the Type of the node.
getParentNode()
Retrieves the parent of the node.
getChildNodes()
Retrieves the children of the node.
getFirstChild()
Retrieves the first child of the node.
getLastChild()
Retrieves the last child of the node.
getPreviousSibling()
Retrieves the previous sibling of the node.
getNextSibling()
Retrieves the next sibling of the node.
getAttributes()
Retrieves the attributes of the node.
getOwnerDocument()
Retrieves the owner document of the node.
insertBefore()
Inserts a child before the reference child.
replaceChild()
Replaces the old child with a new child.
removeChild()
Removes a specified child from a node.
appendChild()
Appends a new child to the node.
hasChildNodes()
Tests if the node has child nodes.
cloneNode()
Clones the node.
Named node map methods --
isNull()
Tests if the NodeMap is NULL.
getNamedItem()
Retrieves the item specified by the name.
setNamedItem()
Sets the item in the map specified by the name.
removeNamedItem()
Removes the item specified by name.
item()
Retrieves the item given the index in the map.
getLength()
Retrieves the number of items in the map.
Node list methods --
isNull()
Tests if the Nodelist is NULL.
item()
Retrieves the item given the index in the nodelist.
getLength()
Retrieves the number of items in the list.
Attr methods --
isNull()
Tests if the attribute Node is NULL.
makeNode()
Casts the atribute to a node.
getQualifiedName()
Retrieves the Qualified Name of the attribute.
getNamespace()
Retrieves the NS URI of the attribute.
getLocalName()
Retrieves the local name of the attribute.
getExpandedName()
Retrieves the expanded name of the attribute.
getName()
Retrieves the name of the attribute.
getSpecified()
Tests if attribute was specified in the owning element.
getValue()
Retrieves the value of the attribute.
setValue()
Sets the value of the attribute.
CData section methods --
isNull()
Tests if the CDataSection is NULL.
makeNode()
Casts the CDatasection to a node.
Character data methods --
isNull()
Tests if the CharacterData is NULL.
makeNode()
Casts the CharacterData to a node.
getData()
Retrieves the data of the node.
setData()
Sets the data to the node.
getLength()
Retrieves the length of the data.
substringData()
Retrieves the substring of the data.
appendData()
Appends the given data to the node data.
insertData()
Inserts the data in the node at the given offSets.
deleteData()
Deletes the data from the given offSets.
replaceData()
Replaces the data from the given offSets.
Comment methods --
isNull()
Tests if the comment is NULL.
makeNode()
Casts the Comment to a node.
DOM implementation methods --
isNull()
Tests if the DOMImplementation node is NULL.
hasFeature()
Tests if the DOM implements a given feature. [Not supported in this release]
Document fragment methods --
isNull()
Tests if the DocumentFragment is NULL.
makeNode()
Casts the Document Fragment to a node.
Document type methods --
isNull()
Tests if the Document Type is NULL.
makeNode()
Casts the document type to a node.
findEntity()
Finds the specified entity in the document type.
findNotation()
Finds the specified notation in the document type.
getPublicId()
Retrieves the public ID of the document type.
getSystemId()
Retrieves the system ID of the document type.
writeExternalDTDToFile()
Writes the document type definition to a file.
writeExternalDTDToBuffer()
Writes the document type definition to a buffer.
writeExternalDTDToClob()
Writes the document type definition to a clob.
getName()
Retrieves the name of the Document type.
getEntities()
Retrieves the node map of entities in the Document type.
getNotations()
Retrieves the nodemap of the notations in the Document type.
Element methods --
isNull()
Tests if the element is NULL.
makeNode()
Casts the element to a node.
getQualifiedName()
Retrieves the qualified name of the element.
getNamespace()
Retrieves the NS URI of the element.
getLocalName()
Retrieves the local name of the element.
getExpandedName()
Retrieves the expanded name of the element.
getChildrenByTagName()
Retrieves the children of the element by tag name.
getElementsByTagName()
Retrieves the elements in the subtree by element.
resolveNamespacePrefix()
Resolve the prefix to a namespace uri.
getTagName()
Retrieves the Tag name of the element.
getAttribute()
Retrieves the attribute node specified by the name.
setAttribute()
Sets the attribute specified by the name.
removeAttribute()
Removes the attribute specified by the name.
getAttributeNode()
Retrieves the attribute node specified by the name.
setAttributeNode()
Sets the attribute node in the element.
removeAttributeNode()
Removes the attribute node in the element.
normalize()
Normalizes the text children of the element. [Not supported in this release]
Entity methods --
isNull()
Tests if the Entity is NULL.
makeNode()
Casts the Entity to a node.
getPublicId()
Retrieves the public Id of the entity.
getSystemId()
Retrieves the system Id of the entity.
getNotationName()
Retrieves the notation name of the entity.
Entity reference methods --
isNull()
Tests if the entity reference is NULL.
makeNode()
Casts the Entity reference to NULL.

Notation methods

--
isNull()
Tests if the notation is NULL.
makeNode()
Casts the notation to a node.
getPublicId()
Retrieves the public Id of the notation.
getSystemId()
Retrieves the system Id of the notation.
Processing instruction methods --
isNull()
Tests if the processing instruction is NULL.
makeNode()
Casts the Processing instruction to a node.
getData()
Retrieves the data of the processing instruction.
getTarget()
Retrieves the target of the processing instruction.
setData()
Sets the data of the processing instruction.
Text methods --
isNull()
Tests if the text is NULL.
makeNode()
Casts the text to a node.
splitText()
Splits the contents of the text node into two text nodes.
Document methods --
isNull()
Tests if the document is NULL.
makeNode()
Casts the document to a node.
newDOMDocument()
Creates a new document.
freeDocument()
Frees the document.
getVersion()
Retrieves the version of the document. [Not supported in this release]
setVersion()
Sets the version of the document. [Not supported in this release]
getCharset()
Retrieves the Character set of the document. [Not supported in this release]
setCharset()
Sets the Character set of the document. [Not supported in this release]
getStandalone()
Retrieves if the document is specified as standalone. [Not supported in this release]
setStandalone()
Sets the document standalone. [Not supported in this release]
writeToFile()
Writes the document to a file.
writeToBuffer()
Writes the document to a buffer.
writeToClob()
Writes the document to a clob.
writeExternalDTDToFile()
Writes the DTD of the document to a file. [Not supported in this release]
writeExternalDTDToBuffer()
Writes the DTD of the document to a buffer. [Not supported in this release]
writeExternalDTDToClob()
Writes the DTD of the document to a clob. [Not supported in this release]
getDoctype()
Retrieves the DTD of the document.
getImplementation()
Retrieves the DOM implementation.
getDocumentElement()
Retrieves the root element of the document.
createElement()
Creates a new element.
createDocumentFragment()
Creates a new document fragment.
createTextNode()
Creates a Text node.
createComment()
Creates a comment node.
createCDATASection()
Creates a CDatasection node.
createProcessingInstruction()
Creates a processing instruction.
createAttribute()
Creates an attribute.
createEntityReference()
Creates an Entity reference.
getElementsByTagName()
Retrieves the elements in the by tag name.

Table F-3 DBMS_XMLDOM Methods Added in Release 2 (9.2.0.2)

Method Syntax
createDocument
FUNCTION createDocument (namspaceURI IN VARCHAR2,
 qualifiedName IN VARCHAR2, doctype IN DOMType
 :=NULL) REURN DocDocument;
getPrefix
FUNCTION getPrefix(n DOMNode) RETURN VARCHAR2;
setPrefix
PROCEDURE setPrefix (n DOMNode) RETURN VARCHAR2;
hasAttributes
FUNCTION hasAttributes (n DOMNode)
  RETURN  BOOLEAN;
getNamedItem
FUNCTION getNamedItem (nnm DOMNamedNodeMap, 
  name IN VARCHAR2, ns IN VARCHAR2) RETURN DOMNode;
setNamedItem
FUNCTION getNamedItem (nnm DOMNamedNodeMap, 
  arg IN DOMNode, ns IN VARCHAR2) RETURN DOMNode;
removeNamedItem
FUNCTION removeNamedItem (nnm DOMNamesNodeMap, 
  name in VARCHAR2, ns IN VARCHAR2) RETURN DOMNode;
getOwnerElement
FUNCTION getOwnerElement (a DOMAttr)
  RETURN DOMElement;
getAttribute
FUNCTION getAttribute (elem DOMElement, 
  name IN VARCHAR2, ns IN VARCHAR2) 
  RETURN VARCHAR2;
hasAttribute
FUNCTION hasAttribute (elem DOMElement, 
  name IN VARCHAR2)  RETURN BOOLEAN;
hasAttribute
FUNCTION hasAttribute (elem DOMElement, 
  name IN VARCHAR2, ns IN VARCHAR2)
  RETURN BOOLEAN;
setAttribute
PROCEDURE setAttribute (elem DOMElement, name IN VARCHAR2, newvalue IN VARCHAR2, ns IN VARCHAR2);
removeAttribute
PROCEDURE removeAttribute (elem DOMElement, 
  name IN VARCHAR2, ns IN VARCHAR2);
getAttributeNode
FUNCTION getAttributeNode(elem DOMElement, 
  name IN VARCHAR2, ns IN VARCHAR2) RETURN DOMAttr;
setAttributeNode
FUNCTION setAttributeNode(elem DOMElement, 
  newAttr IN DOMAttr, ns IN VARCHAR2) 
  RETURN DOMAttr;
createElement
FUNCTION createElement (doc DOMDocument, 
  tagname IN VARCHAR2, ns IN VARCHAR2) 
  RETURN DOMElement;
createAttribute
FUNCTION createAttribute (doc DOMDocument, 
  name IN VARCHAR2, ns IN VARCHAR2) RETURN DOMAttr;

PL/SQL Parser for XMLType (DBMS_XMLPARSER)

You can access the content and structure of XML documents through the PL/SQL Parser for XMLType (DBMS_XMLPARSER).

Table F-4 lists the PL/SQL Parser for XMLType (DBMS_XMLPARSER) functions and procedures.

Table F-4 DBMS_XMLPARSER Functions and Procedures

Functions/Procedures Description
parse()
Parses XML stored in the given URL/file.
newParser()
Returns a new parser instance
parseBuffer()
Parses XML stored in the given buffer
parseClob()
Parses XML stored in the given clob
parseDTD()
Parses DTD stored in the given url/file
parseDTDBuffer()
Parses DTD stored in the given buffer
parseDTDClob()
Parses DTD stored in the given clob
setBaseDir()
Sets base directory used to resolve relative URLs.
showWarnings()
Turns warnings on or off.
setErrorLog()
Sets errors to be sent to the specified file
setPreserveWhitespace()
Sets white space preserve mode
setValidationMode()
Sets validation mode.
getValidationMode()
Returns validation mode.
setDoctype()
Sets DTD.
getDoctype()
Gets DTD Parser.
getDocument()
Gets DOM document.
freeParser()
Frees a parser object.
getReleaseVersion()
Returns the release version of Oracle XML Parser for PL/SQL.

PL/SQL XSLT Processor for XMLType (DBMS_XSLPROCESSOR)

This PL/SQL implementation of the XSL processor follows the W3C XSLT Working Draft (Rev WD-xslt-19990813).

Table F-5 summarizes the PL/SQL XSLT Processor for XMLType (DBMS_XSLPROCESSOR) functions and procedures.

Table F-5 PL/SQL XSLT Processor for XMLType (DBMS_XSLPROCESSOR) Functions

Functions and Procedures Description
newProcessor()
Returns a new processor instance.
processXSL()
Transforms an input XML document.
showWarnings()
Turns warnings on or off.
setErrorLog()
Sets errors to be sent to the specified file.
newStylesheet()
Creates a new style sheet using the given input and reference URLs.
transformNode()
Transforms a node in a DOM tree using the given style sheet.
selectNodes()
Selects nodes from a DOM tree that match the given pattern.
selectSingleNodes()
Selects the first node from the tree that matches the given pattern.
valueOf()
Retrieves the value of the first node from the tree that matches the given pattern
setParam()
Sets a top-level parameter in the style sheet
removeParam()
Removes a top-level style-sheet parameter
resetParams()
Resets the top-level style-sheet parameters
freeStylesheet()
Frees a style-sheet object
freeProcessor()
Frees a processor object

DBMS_XMLSCHEMA

This package is created by dbmsxsch.sql during the Oracle XML DB installation. It provides procedures for registering and deleting your XML schemas. Table F-6 summarizes the DBMS_XMLSCHEMA functions and procedures.

Table F-6 DBMS_XMLSCHEMA Functions and Procedures

Constant Description

registerSchema()

procedure registerSchema(schemaURL IN VARCHAR2, schemaDoc IN VARCHAR2, local IN BOOLEAN := TRUE, genTypes IN BOOLEAN := TRUE, genbean IN BOOLEAN := FALSE, genTables IN BOOLEAN := TRUE, force IN BOOLEAN := FALSE, owner IN VARCHAR2 := null);

procedure registerSchema(schemaURL IN VARCHAR2, schemaDoc IN CLOB, local IN BOOLEAN := TRUE, genTypes IN BOOLEAN := TRUE, genbean IN BOOLEAN := FASLE, force IN BOOLEAN := FALSE, owner IN VARCHAR2 := null);

procedure registerSchema(schemaURL IN varchar2, schemaDoc IN BFILE,local IN BOOLEAN := TRUE,genTypes IN BOOLEAN := TRUE, genbean IN BOOLEAN := FALSE, genTables IN BOOLEAN := TRUE,force IN BOOLEAN := FALSE, owner IN VARCHAR2 := '',csid IN NUMBER);

procedure registerSchema(schemaURL IN VARCHAR2, schemaDoc IN SYS.XMLType, local IN BOOLEAN := TRUE, genTypes IN BOOLEAN := TRUE, genbean IN BOOLEAN := FALSE, force IN BOOLEAN := FALSE, owner IN VARCHAR2 := null);

Registers the specified XML schema for use by Oracle XML DB. This schema can then be used to store documents that conform to it.

Parameters:

schemaURL - URL that uniquely identifies the schema document. This value is used to derive the path name of the schema document within the XML DB hierarchy.

schemaDoc - a valid XML schema document

local - is this a local or global schema? By default, all schemas are registered as local schemas, that is under /sys/schemas/<username>/... If a schema is registered as global, then it is added under /sys/schemas/PUBLIC/.... You need write privileges on the preceding directory to be able to register a schema as global.

genTypes - should the schema compiler generate object types? By default, TRUE

genbean - should the schema compiler generate Java beans? By default, FALSE.

genTables - should the schema compiler generate default tables? By default, TRUE

force - if this parameter is set to TRUE, then the schema registration will not raise errors. Instead, it creates an invalid XML schema object in case of any errors. By default, the value of this parameter is FALSE.

owner - specifies the name of the database user owning the XML schema object. By default, the user registering the XML schema owns the XML schema object. Can be used to register an XML schema to be owned by a different database user.

csid - specifies the character set id of the input BLOB or BFILE. If zero is specified then the character encoding of the input is auto-detected as defined by the W3C XML Recommendation.

procedure registerSchema(schemaURL IN varchar2, schemaDoc IN BLOB,local IN BOOLEAN := TRUE, TRUE, genbean IN BOOLEAN := FALSE, genTables IN BOOLEAN := TRUE,force IN BOOLEAN := FALSE, owner IN VARCHAR2 := '', csid IN NUMBER);  

registerURI()

procedure registerURI(schemaURL IN varchar2, schemaDocURI IN varchar2, local IN BOOLEAN := TRUE, genTypes IN BOOLEAN := TRUE, genbean IN BOOLEAN := FALSE, genTables IN BOOLEAN := TRUE, force IN BOOLEAN := FALSE, owner IN VARCHAR2 := null);
Registers an XML schema specified by a URI name.

deleteSchema()

procedure deleteSchema(schemaURL IN varchar2, delete_option IN pls_integer := DELETE_RESTRICT);
Removes the XML schema from Oracle XML DB.

generateBean()

procedure generateBean(schemaURL IN varchar2);
Generates the Java Bean code corresponding to a registered XML schema.

compileSchema()

procedure compileSchema( schemaURL IN varchar2);
Recompiles an already registered XML schema. Useful for bringing an invalid schema to a valid state.

generateSchema()

function generateSchemas(schemaName IN varchar2, typeName IN varchar2, elementName IN varchar2 := NULL, schemaURL IN varchar2 := NULL, annotate IN BOOLEAN := TRUE, embedColl IN BOOLEAN := TRUE ) return sys.XMLSequenceType;

function generateSchema( schemaName IN varchar2, typeName IN varchar2, elementName IN varchar2 := NULL, recurse IN BOOLEAN := TRUE, annotate IN BOOLEAN := TRUE, embedColl IN BOOLEAN := TRUE ) return sys.XMLType;

Generates XML schema(s) from an Oracle type name.

DBMS_XMLSCHEMA constants:

Oracle XML DB XML Schema Catalog Views

Table F-7 lists the Oracle XML DB XML schema catalog views.

Table F-7 Oracle XML DB: XML Schema Catalog View

Schema Description
USER_XML_SCHEMAS
Lists all registered XML Schemas owned by the user.
ALL_XML_SCHEMAS
Lists all registered XML Schemas usable by the current user.
DBA_XML_SCHEMAS
Lists all registered XML Schemas in Oracle XML DB.
DBA_XML_TABLES
Lists all XMLType tables in the system.
USER_XML_TABLES
Lists all XMLType tables owned by the current user.
ALL_XML_TABLES
Lists all XMLType tables usable by the current user.
DBA_XML_TAB_COLS
Lists all XMLType table columns in the system.
USER_XML_TAB_COLS
Lists all XMLType table columns in tables owned by the current user.
ALL_XML_TAB_COLS
Lists all XMLType table columns in tables usable by the current user.
DBA_XML_VIEWS
Lists all XMLType views in the system.
USER_XML_VIEWS
Lists all XMlType views owned by the current user.
ALL_XML_VIEWS
Lists all XMLType views usable by the current user.
DBA_XML_VIEW_COLS
Lists all XMLType view columns in the system.
USER_XML_VIEW_COLS
Lists all XMLType view columns in views owned by the current user.
ALL_XML_VIEW_COLS
Lists all XMLType view columns in views usable by the current user.

Resource API for PL/SQL (DBMS_XDB)

Resource API for PL/SQL (DBMS_XDB) PL/SQL package provides functions for the following Oracle XML DB tasks:

Table F-8 summarizes the DBMS_XDB functions and procedures.

Table F-8 DBMS_XDB Functions and Procedures

Function/Procedure Description
getAclDocument()
FUNCTION getAclDocument(abspath IN VARCHAR2) RETURN sys.xmltype;
Retrieves ACL document that protects resource given its path name.
getPrivileges()
FUNCTION getPrivileges(res_path IN VARCHAR2) RETURN sys.xmltype;
Gets all privileges granted to the current user on the given XML DB resource.
changePrivileges()
FUNCTION changePrivileges(res_path IN VARCHAR2, ace IN XMLType) RETURN pls_integer;
Adds the given access control entry (ACE) to the given resource access control list (ACL).
checkPrivileges()
FUNCTION checkPrivileges(res_path IN VARCHAR2, privs IN XMLType) RETURN pls_integer;
Checks access privileges granted to the current user on the specified XML DB resource.
setacl()
PROCEDURE setacl(res_path IN VARCHAR2, acl_path IN VARCHAR2);
Sets the ACL on the given XML DB resource to be the ACL specified.
AclCheckPrivileges()
FUNCTION AclCheckPrivileges(acl_path IN VARCHAR2,owner IN VARCHAR2, privs IN XMLType) RETURN pls_integer;
Checks access privileges granted to the current user by specified ACL document on a resource whose owner is specified by the 'owner' parameter.
LockResource()
FUNCTION LockResource(path IN VARCHAR2, depthzero IN BOOLEAN,shared IN boolean) RETURN BOOLEAN;
Gets a WebDAV-style lock on that resource given a path to that resource.
GetLockToken()
PROCEDURE GetLockToken(path IN VARCHAR2,locktoken OUT VARCHAR2);
Returns that resource lock token for the current user given a path to a resource.
UnlockResource()
FUNCTION UnlockResource(path IN VARCHAR2,deltoken IN VARCHAR2) RETURN BOOLEAN;
Unlocks the resource given a lock token and a path to the resource.
CreateResource()
FUNCTION CreateResource(path IN VARCHAR2,data IN VARCHAR2) RETURN BOOLEAN;
FUNCTION CreateResource(path IN VARCHAR2, data IN SYS.XMLTYPE) RETURN BOOLEAN;
FUNCTION CreateResource(path IN VARCHAR2, datarow IN REF SYS.XMLTYPE) RETURN BOOLEAN
FUNCTION CreateResource(path IN VARCHAR2, data IN CLOB) RETURN BOOLEAN;
FUNCTION CreateResource(abspath IN VARCHAR2,data IN BFILE,csid IN NUMBER:= 0) RETURN BOOLEAN;
FUNCTION CreateResource(abspath IN VARCHAR2, data IN BLOB,csid IN NUMBER:= 0) RETURN BOOLEAN;
Creates a new resource.
CreateFolder()
FUNCTION CreateFolder(path IN VARCHAR2) RETURN BOOLEAN;
Creates a new folder resource in the hierarchy.
DeleteResource()
PROCEDURE DeleteResource(path IN VARCHAR2);
Deletes a resource from the hierarchy.
Link()
PROCEDURE Link(srcpath IN VARCHAR2, linkfolder IN VARCHAR2, linkname IN VARCHAR2);
Creates a link to an existing resource.
CFG_Refresh()
PROCEDURE CFG_Refresh;
Refreshes the session configuration information to the latest configuration.
CFG_Get()
FUNCTION CFG_Get RETURN SYS.XMLType;
Retrieves the session configuration information.
CFG_Update()
PROCEDURE CFG_Update(xdbconfig IN SYS.XMLTYPE);
Updates the configuration information.

DBMS_XMLGEN

PL/SQL package DBMS_XMLGEN transforms SQL query results into a canonical XML format. It inputs an arbitrary SQL query, converts it to XML, and returns the result as a CLOB. DBMS_XMLGEN is similar to the DBMS_XMLQUERY, except that it is written in C and compiled in the kernel. This package can only be run in the database.

Table F-9 summarizes the DBMS_XMLGEN functions and procedures.

Table F-9 DBMS_XMLGEN Functions and Procedures

Function/Procedure Description

newContext()

Creates a new context handle.

setRowTag()

Sets the name of the element enclosing each row of the result. The default tag is ROW.

setRowSetTag ()

Sets the name of the element enclosing the entire result. The default tag is ROWSET.

getXML()

Gets the XML document.

getNumRowsProcessed()

Gets the number of SQL rows that were processed in the last call to getXML.

setMaxRows()

Sets the maximum number of rows to be fetched each time.

setSkipRows()

Sets the number of rows to skip every time before generating the XML. The default is 0.

setConvertSpecialChars()

Sets whether special characters such as $, which are non-XML characters, should be converted or not to their escaped representation. The default is to perform the conversion.

convert()

Converts the XML into the escaped or unescaped XML equivalent.

useItemTagsForColl()

Forces the use of the collection column name appended with the tag _ITEM for collection elements. The default is to set the underlying object type name for the base element of the collection.

restartQUERY()

Restarts the query to start fetching from the beginning.
closeContext() Closes the context and releases all resources.

RESOURCE_VIEW, PATH_VIEW

Oracle XML DB RESOURCE_VIEW and PATH_VIEW provide a mechanism for SQL-based access of data stored in the Oracle XML DB repository. Data stored in the Oracle XML DB repository through protocols such as FTP or WebDAV API can be accessed in SQL through RESOURCE_VIEW and PATH_VIEW.

Oracle XML DB resource API for PL/SQL is based on RESOURCE_VIEW, PATH_VIEW and some PL/SQL packages. It provides query and DML functionality. PATH_VIEW has one row for each unique path in the repository, whereas RESOURCE_VIEW has one row for each resource in the repository.

Table F-10 summarizes the Oracle XML DB resource API for PL/SQL operators.

Table F-10 RESOURCE_VIEW, PATH_VIEW Operators

Operator Description
UNDER_PATH
INTEGER UNDER_PATH(
  resource_column, pathname);
INTEGER UNDER_PATH(
  resource_column, depth,
  pathname);
INTEGER UNDER_PATH(
  resource_column, pathname,
  correlation);
INTEGER UNDER_PATH(
  resource_column, depth,
  pathname, correlation);
Using the Oracle XML DB hierarchical index, returns sub-paths of a particular path.

Parameters:

  • resource_column - column name or column alias of the 'resource' column in the path_view or resource_view.

  • pathname - path name to resolve.

  • depth - maximum depth to search; a depth of less than 0 is treated as 0.

  • correlation - integer that can be used to correlate the UNDER_PATH operator (a primary operator) with ancillary operators (PATH and DEPTH).

EQUALS_PATH
INTEGER EQUALS_PATH(
  resource_column, pathname);
Finds the resource with the specified path name.
PATH
VARCHAR2 PATH(correlation);
Returns the relative path name of the resource under the specified path name argument.
DEPTH
INTEGER DEPTH(correlation)
Returns the folder depth of the resource under the specified starting path.

DBMS_XDB_VERSION

DBMS_XDB_VERSION along with DBMS_XDB implement the Oracle XML DB versioning API.

Table F-11 summarizes the DBMS_XDB_VERSION functions and procedures.

Table F-11 DBMS_XDB_VERSION Functions and Procedures

Function/Procedure Description
MakeVersioned()
FUNCTION MakeVersioned(pathname VARCHAR2) RETURN dbms_xdb.resid_type;
Turns a regular resource whose path name is given into a version-controlled resource.
Checkout()
PROCEDURE Checkout(pathname VARCHAR2);
Checks out a VCR before updating or deleting it.
Checkin()
FUNCTION Checkin(pathname VARCHAR2) RETURN dbms_xdb.resid_type;
Checks in a checked-out VCR and returns the resource id of the newly-created version.
Uncheckout()
FUNCTION Uncheckout( pathname VARCHAR2) RETURN dbms_xdb.resid_type;
Checks in a checked-out resource and returns the resource id of the version before the resource is checked out.
GetPredecessors()
FUNCTION GetPredecessors(pathname VARCHAR2) RETURN resid_list_type;
Retrieves the list of predecessors by path name.
GetPredsByResId()
FUNCTION GetPredsByResId(resid resid_type) RETURN resid_list_type;
Retrieves the list of predecessors by resource id.
GetResourceByResId()
FUNCTION GetResourceByResId(resid resid_type) RETURN XMLType;
Obtains the resource as an XMLType, given the resource objectID.
GetSuccessors()
FUNCTION GetSuccessors( pathname VARCHAR2) RETURN resid_list_type;
Retrieves the list of successors by path name.
GetSuccsByResId()
FUNCTION GetSuccsByResId( resid resid_type) RETURN resid_list_type;
Retrieves the list of successors by resource id.

DBMS_XDBT

Using DBMS_XDBT you can set up an Oracle Text ConText index on the Oracle XML DB repository hierarchy. DBMS_XDBT creates default preferences and the Oracle Text index. It also sets up automatic synchronization of the ConText index.

DBMS_XDBT contains variables that describe the configuration settings for the ConText index. These are intended to cover the basic customizations that installations may require, but they are not a complete set.

Use DBMS_XDBT for the following tasks:

Table F-12 summarizes the DBMS_XDBT functions and procedures.

Table F-12 DBMS_XDBT Functions and Procedures

Procedure/Function Description
dropPreferences() Drops any existing preferences.
createPreferences() Creates preferences required for the ConText index on the XML DB hierarchy.
createDatastorePref() Creates a USER datastore preference for the ConText index.
createFilterPref() Creates a filter preference for the ConText index.
createLexerPref() Creates a lexer preference for the ConText index.
createWordlistPref() Creates a stoplist for the ConText index.
createStoplistPref() Creates a section group for the ConText index.
createStoragePref() Creates a wordlist preference for the ConText index.

createSectiongroupPref()

Creates a storage preference for the ConText index.

createIndex()

Creates the ConText index on the XML DB hierarchy.

configureAutoSync()

Configures the ConText index for automatic maintenance (SYNC).

New PL/SQL APIs to Support XML Data in Different Character Sets

The following lists the PL/SQL APIs added for this release to load, register schema, and retrieve XML data encoded in different character sets.:


New DBMS_XDB APIs

New CreateResource for BFILE and BLOB with csid argument

FUNCTION CreateResource(abspath IN VARCHAR2,
                         data IN BLOB, 
                         csid IN NUMBER := 0)
   RETURN BOOLEAN;
FUNCTION CreateResource(abspath IN VARCHAR2, 
                         data IN BFILE, 
                         csid IN NUMBER := 0) 
   RETURN BOOLEAN;

New DBMS_XMLSCHEMA APIs

New registerSchema for BLOB and BFILE with csid argument.

procedure registerSchema(schemaURL IN varchar2, 
                           schemaDoc IN BLOB, 
                           local IN BOOLEAN := TRUE, 
                           genTypes IN BOOLEAN := TRUE, 
                           genbean IN BOOLEAN := FALSE, 
                           genTables IN BOOLEAN := TRUE, 
                           force IN BOOLEAN := FALSE, 
                           owner IN VARCHAR2 := '', 
                           csid IN NUMBER);

procedure registerSchema(schemaURL IN varchar2, 
                           schemaDoc IN BFILE, 
                           local IN BOOLEAN := TRUE, 
                           genTypes IN BOOLEAN := TRUE, 
                           genbean IN BOOLEAN := FALSE, 
                           genTables IN BOOLEAN := TRUE, 
                           force IN BOOLEAN := FALSE, 
                           owner IN VARCHAR2 := '', 
                           csid IN NUMBER);

New *URIType APIs

New getBlob function with csid argument.

URIType: MEMBER FUNCTION getBlob(csid IN NUMBER) RETURN blob,
FTPURIType: OVERRIDING MEMBER FUNCTION getBlob(csid IN NUMBER) RETURN blob,
HttpUriType: OVERRIDING MEMBER FUNCTION getBlob(csid IN NUMBER) RETURN blob, 
DBURIType: OVERRIDING MEMBER FUNCTION getBlob(csid IN NUMBER) RETURN blob, 
XDBURIType: OVERRIDING MEMBER FUNCTION getBlob(csid IN NUMBER) RETURN blob,

New DBMS_XSLPROCESSOR Modified read2Clob and clob2file routines to accept csid argument.
FUNCTION read2clob(flocation VARCHAR2, fname VARCHAR2, csid IN NUMBER := 0) 
  RETURN CLOB; 
PROCEDURE clob2file(cl CLOB, flocation VARCHAR2, 
                    fname VARCHAR2, csid IN NUMBER := 0);

New PL/SQL XMLType APIs

New XMLType constructors for BLOB and BFILE with csid:

CONSTRUCTOR FUNCTION XMLType(xmlData IN blob, csid IN number, 
                              schema IN varchar2 := NULL, 
                              validated IN number := 0, 
                              wellformed IN number := 0) 
              RETURN self AS result, CONSTRUCTOR FUNCTION XMLType(xmlData IN bfile, csid IN number, 
                            schema IN varchar2 := NULL, 
                            validated IN number := 0,
                            wellformed IN number := 0) 
              RETURN self AS result,

New createXML methods for BLOB and BFILE with csid.

STATIC FUNCTION createXML(xmlData IN blob, csid IN number, schema IN varchar2, 
                           validated IN number := 0, wellformed IN number := 0) 
          RETURN sys.XMLType
STATIC FUNCTION createXML(xmlData IN BFILE, csid IN number, schema IN varchar2,
                           validated IN number := 0, wellformed IN number := 0) 
          RETURN sys.XMLType.
MEMBER FUNCTION getBlobVal(csid IN number) RETURN BLOB