Skip Headers

Oracle9i XML Database Developer's Guide - Oracle XML DB
Release 2 (9.2)

Part Number A96620-02
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 Go to next page
View PDF

F
Oracle XML DB XMLType API, PL/SQL and Resource PL/SQL APIs: Quick Reference

This appendix provides a summary of the following Oracle XML DB SQL and PL/SQL APIs:

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.

See Also:
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

onstructor 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)

--

--

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 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, 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)

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, 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, it must be freed after use.

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 stylesheet argument and the top-level parameters passed as a string of name=value pairs. If any argument other than the parammap is NULL, a NULL is returned.

Parameter

xsl - XSL stylesheet 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 schemaURL.

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 an error is raised; else, the document's 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, conformance is checked against the XMLType instance's own schema.

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 need to check conformance against a specific elements.

PL/SQL DOM API for XMLType (DBMS_XMLDOM)

Table F-2 lists the PL/SQL 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).

See Also:

Chapter 8, "PL/SQL API for XMLType"

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 Attribute 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.

getSpecifiied()

Tests if attribute was specified in the owning element.

getValue()

Retrieves the value of the attribute.

setValue()

Sets the value of the attribute.

C data section methods

--

isNull()isNull()

Tests if the CDataSection is NULL.

makeNode()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 nodemap 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 2 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.

See Also:

Chapter 8, "PL/SQL API for XMLType"

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.

See Also:

Chapter 8, "PL/SQL API for XMLType"

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 stylesheet using the given input and reference URLs.

transformNode()

Transforms a node in a DOM tree using the given stylesheet.

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 stylesheet

removeParam()

Removes a top-level stylesheet parameter

resetParams()

Resets the top-level stylesheet parameters

freeStylesheet()

Frees a stylesheet 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.

See Also:

Chapter 5, "Structured Mapping of XMLType"

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, force IN BOOLEAN := FALSE, owner IN VARCHAR2 := null);

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);

procedure registerSchema(schemaURL IN VARCHAR2, schemaDoc IN SYS.URIType, 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, 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 - sShould the schema compiler generate default tables? By default, TRUE

force - if this parameter is set to TRUE, 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.

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.

See Also:

Chapter 16, "Oracle XML DB Resource API for PL/SQL (DBMS_XDB)"

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 ACE to the given resource's 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's 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(path IN VARCHAR2, data IN BFILE) 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's configuration information to the latest configuration.

CFG_Get()

FUNCTION CFG_Get RETURN SYS.XMLType;

Retrieves the session's 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.

See Also:

Chapter 10, "Generating XML Data from the Database"

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 and PATH VIEWS.

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 REOURCE_VIEW has one row for each resource in the Repository.

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

See Also:

Chapter 15, "RESOURCE_VIEW and PATH_VIEW"

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

EQUALS_PATH INTEGER EQUALS_PATH( resource_column, pathname);

Finds the resource with the specified path name.

PATH

PATH VARCHAR2 PATH( correlation);

Returns the relative path name of the resource under the specified path name argument.

DEPTH

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.

See Also:

Chapter 14, "Oracle XML DB Versioning"

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.

See Also:

Oracle9i XML API Reference - XDK and Oracle XML DB

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).