Oracle DBMS_XMLSCHEMA
Version 12.1.0.1

General Information
Library Note Morgan's Library Page Footer
The Library is currently in the process of being upgraded from Oracle Database Version 11.2.0.3 to 12.1.0.1. Demos are being upgraded to reflect the new Container paradigm as well as EBR (Edition Based Redefinition) and may contain references to CDBs, PDBs, and other objects you may not be familiar with such as CDB_OBJECTS_AE: Welcome to 12c.
Purpose Used to register XML schemas with XDBf
AUTHID CURRENT_USER
Constants
Name Data Type Value
DELETE_RESTRICT NUMBER 1
DELETE_INVALIDATE NUMBER 2
DELETE_CASCADE NUMBER 3
DELETE_CASCADE_FORCE NUMBER 4
DELETE_MIGRATE NUMBER 8
ENABLE_HIERARCHY_NONE PLS_INTEGER 1
ENABLE_HIERARCHY_CONTENTS PLS_INTEGER 2
ENABLE_HIERARCHY_RESMETADATA PLS_INTEGER 3
ENABLE_HIERARCHY_VERSION PLS_INTEGER 4
ENABLE_HIERARCHY_LINKS PLS_INTEGER 8
REGISTER_NODOCID NUMBER 1
REGISTER_BINARYXML NUMBER 2
REGISTER_NT_AS_IOT NUMBER 4
REGISTER_CSID_NULL NUMBER -1
COPYEVOLVE_BINARY_XML NUMBER 1
INPLACE_EVOLVE NUMBER 1
INPLACE_TRACE NUMBER 2
Data Types TYPE URLARR IS VARRAY(1000) OF VARCHAR2(1000);
/

TYPE XMLARR IS VARRAY(1000) OF XMLType;
/

TYPE UNAME_ARR IS VARRAY(1000) OF VARCHAR2(100);
/
Dependencies
DBMS_LOB DBMS_XMLSCHEMA_INT XDB$STRING_LIST_T
DBMS_METADATA_HACK NLS_DATABASE_PARAMETERS XMLSCHEMA_LIB
DBMS_METADATA_UTIL URIFACTORY XMLSEQUENCETYPE
DBMS_REGXDB URITYPE XMLTYPE
Documented Yes
Exceptions
Error Code Reason
ORA-31001 Invalid resource handle or path name
First Available Created 01-Dec-2000
Security Model Owned by XDB with EXECUTE granted to PUBLIC
Source {ORACLE_HOME}/rdbms/admin/dbmsxsch.sql
Subprograms
 
COMPILESCHEMA
Used to re-compile an already registered XML schema. This is useful for bringing a schema in an invalid state to a valid state dbms_xmlschema.compileSchema(schemaURL IN VARCHAR2);
PRAGMA SUPPLEMENTAL_LOG_DATA(compileSchema, UNSUPPORTED_WITH_COMMIT);
TBD
 
CONVERTTODATE
Converts the string representation of the following specified XML Schema types into the Oracle DATE representation using a default reference date and format mask. dbms_xmlschema.convertToDate(
strval      IN VARCHAR2,
xmltypename IN VARCHAR2)
RETURN DATE DETERMINISTIC PARALLEL_ENABLE;
TBD
 
CONVERTTOTS
Converts the string representation of the following specified XML Schema types into the Oracle TIMESTAMP representation using a default reference date and format mask. dbms_xmlschema.convertToTS(strval VARCHAR2, xmltypename VARCHAR2)
RETURN TIMESTAMP DETERMINISTIC PARALLEL_ENABLE;
TBD
 
CONVERTTOTSWITHTZ
Converts the string representation of the following specified XML Schema types into the Oracle TIMESTAMP WITH TIMEZONE representation using a default reference date and format mask. dbms_xmlschema.convertToTSWithTZ(strval VARCHAR2, xmltypename VARCHAR2)
RETURN TIMESTAMP WITH TIME ZONE DETERMINISTIC PARALLEL_ENABLE;
TBD
 
COPYEVOLVE
Undocumented dbms_xmlschema.copyEvolve(
schemaURLs      IN XDB$STRING_LIST_T,
newSchemas      IN XMLSequenceType,
transforms      IN XMLSequenceType := NULL,
preserveOldDocs IN BOOLEAN  := FALSE,
mapTabName      IN VARCHAR2 := NULL,
generateTables  IN BOOLEAN  := TRUE,
force           IN BOOLEAN  := FALSE,
schemaOwners    IN XDB$STRING_LIST_T := NULL,
parallelDegree  IN PLS_INTEGER := 0,
options         IN PLS_INTEGER := 0);
PRAGMA SUPPLEMENTAL_LOG_DATA(CopyEvolve, UNSUPPORTED_WITH_COMMIT);
TBD
 
DELETESCHEMA
Identifies the schema to be deleted dbms_xmlschema.deleteSchema(
schemaURL     IN VARCHAR2,
delete_option IN PLS_INTEGER := DELETE_RESTRICT);
PRAGMA SUPPLEMENTAL_LOG_DATA(deleteSchema, UNSUPPORTED_WITH_COMMIT);
-- from $ORACLE_HOME/rdbms/admin/catnorul.sql
exec dbms_xmlschema.deleteschema('http://xmlns.oracle.com/rlmgr/rulecond.xsd');
 
GENERATEBEAN
Used to generate the Java bean code corresponding to a registered XML schema dbms_xmlschema.generateBean(schemaURL IN VARCHAR2);
TBD
 
GENERATESCHEMA
Generates an XML schema from an Oracle type name. generateSchemas returns a collection of XMLTypes. generateSchema inlines them all in one schema (XMLType). dbms_xmlschema.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;
conn uwclass/uwclass@pdbdev

CREATE TYPE server_t AUTHID DEFINER AS OBJECT (
srvr_id    NUMBER(10),
network_id NUMBER(10),
status     VARCHAR2(1),
latitude   FLOAT(20),
longitude  FLOAT(20),
netaddress VARCHAR2(15));
/

CREATE TYPE serv_inst_t AUTHID DEFINER AS OBJECT (
siid          NUMBER(10),
si_status     VARCHAR2(15),
srvr_type     VARCHAR2(5),
installstatus VARCHAR2(1),
location_code NUMBER(10),
custacct_id   VARCHAR2(10),
ws_id         NUMBER(10),
srvr_id       server_t);
/

SELECT dbms_xmlschema.generateSchema(USER, 'SERV_INST_T') AS result
FROM DUAL;
 
GENERATESCHEMAS
Generates XML schemas from an Oracle type name. One XMLSchema document for each database schema.
dbms_xmlschema.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;
TBD
 
INPLACEEVOLVE
Undocumented
dbms_xmlschema.inplaceEvolve(
schemaURL IN VARCHAR2,
diffXML   IN SYS.XMLTYPE,
flags     IN NUMBER := 1);
PRAGMA SUPPLEMENTAL_LOG_DATA(InPlaceEvolve, UNSUPPORTED_WITH_COMMIT);
TBD
 
PURGESCHEMA
Purges a schema that was previously marked delete with hide mode dbms_xmlschema.purgeSchema(procedure purgeSchema(schema_id IN RAW);
PRAGMA SUPPLEMENTAL_LOG_DATA(purgeSchema, UNSUPPORTED_WITH_COMMIT);
TBD
 
REGISTERSCHEMA
Register XML schemas with XDB

Overload 1
dbms_xmlschema.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    := '',
enableHierarchy IN PLS_INTEGER := ENABLE_HIERARCHY_CONTENTS,
options         IN PLS_INTEGER := 0);
PRAGMA SUPPLEMENTAL_LOG_DATA(registerSchema, UNSUPPORTED_WITH_COMMIT);
-- from $ORACLE_HOME/rdbms/admin/catxdav.sql

IF IsDowngrade THEN
  xdb.dbms_xmlschema.registerSchema(DAVURL, DAVXSD, FALSE, TRUE, FALSE, TRUE, FALSE, 'XDB');
ELSE
  xdb.dbms_xmlschema.registerSchema(DAVURL, DAVXSD, FALSE, FALSE, FALSE, TRUE, FALSE, 'XDB', options => DBMS_XMLSCHEMA.REGISTER_BINARYXML);
END IF;
Another Demo From Oracle (unedited) ************************************************************************
* Registering the account.xsd Schema using Oracle XML DB
************************************************************************

DECLARE
  doc varchar2(2000) := '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb">
       <xs:element name="ACCOUNT">
         <xs:complexType xdb:SQLType="XML_ACCOUNT">
           <xs:sequence>
             <xs:element name="ACC_NO" type="xs:float" nillable="false"/>
             <xs:element name="CST_ID" type="xs:float"/>
             <xs:element name="ACC_BALANCE" type="xs:float" default="0" nillable="false"/>
             <xs:element name="ACC_CREDITLIMIT" type="xs:float"/>
             <xs:element name="ACC_CREATEDATE" type="xs:date"/>
             <xs:element name="ACC_CARDTYPE" type="xs:string"/>
             <xs:element name="ACC_ENABLED" type="xs:boolean"/>
           </xs:sequence>
         </xs:complexType>
       </xs:element>
  </xs:schema>';
BEGIN
 -- use the pl/sql package to register the schema
 dbms_xmlschema.registerSchema('http://otn.oracle.com/account.xsd', doc);
END;

*************************************************************************
* Registering the customer.xsd Schema using Oracle XML DB
*************************************************************************

DECLARE
  doc varchar2(2000) := '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb">
    <xs:complexType name="CADDRType" xdb:SQLType="XML_CADDR" >
      <xs:sequence>
        <xs:element name="CST_ADDR_STREET" type="xs:string"/>
        <xs:element name="CST_ADDR_CITY" type="xs:string"/>
        <xs:element name="CST_ADDR_STATE" type="xs:string"/>
        <xs:element name="CST_ADDR_ZIP" type="xs:string"/>
        <xs:element name="CST_ADDR_COUNTRY" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
    <xs:element name="CUSTOMER">
      <xs:complexType xdb:SQLType="XML_CUSTOMER">
        <xs:sequence>
          <xs:element name="CST_ID" type="xs:float" nillable="false"/>
          <xs:element name="CST_NAME" type="xs:string"/>
          <xs:element name="CST_TYPE" type="xs:string"/>
          <xs:element name="CST_EMAIL" type="xs:string"/>
          <xs:element name="CST_ADDR" type="CADDRType"/>
          <xs:element name="CST_PHONE" type="xs:string"/>
          <xs:element name="CST_JOINDATE" type="xs:date"/>
          <xs:element name="CST_DESCRIPTION" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
  </xs:schema>';
BEGIN
 -- use the pl/sql package to register the schema
 dbms_xmlschema.registerSchema('http://otn.oracle.com/customer.xsd', doc);
END;

***************************************************************************
* Registering the transaction.xsd Schema using Oracle XML DB
***************************************************************************

DECLARE
  doc varchar2(2000) := '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb">
   <xs:element name="TRANSACTION">
     <xs:complexType xdb:SQLType="XML_TRANSACTION">
       <xs:sequence>
          <xs:element name="TR_ID" type="xs:float" nillable="false"/>
          <xs:element name="ACC_NO_DEBIT" type="xs:float"/>
          <xs:element name="ACC_NO_CREDIT" type="xs:float"/>
          <xs:element name="TR_AMOUNT" type="xs:float" default="0" nillable="false"/>
          <xs:element name="TR_DATE" type="xs:dateTime"/>
          <xs:element name="TR_DESCRIPTION" type="xs:string"/>
       </xs:sequence>
     </xs:complexType>
   </xs:element>
  </xs:schema>';
BEGIN
 -- use the pl/sql package to register the schema
 dbms_xmlschema.registerSchema('http://otn.oracle.com/transaction.xsd', doc);
END;
Overload 2 (new 11.2.0.2 parameters) dbms_xmlschema.registerSchema(
schemaURL       IN VARCHAR2,
schemaDoc       IN CLOB,
local           IN BOOLEAN     := TRUE,
genTypes        IN BOOLEAN     := TRUE,
genbean         IN BOOLEAN     := FALSE,
genTables       IN BOOLEAN     := TRUE,
force           IN BOOLEAN     := FALSE,
owner           IN VARCHAR2    := '',
enableHierarchy IN PLS_INTEGER := ENABLE_HIERARCHY_CONTENTS,
options         IN PLS_INTEGER := 0,
schemaoid       IN RAW         := NULL,
import_options IN pls_integer  := 0);
PRAGMA SUPPLEMENTAL_LOG_DATA(registerSchema, UNSUPPORTED_WITH_COMMIT);
TBD
Overload 3 dbms_xmlschema.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   := REGISTER_CSID_NULL,
enableHierarchy IN PLS_INTEGER := ENABLE_HIERARCHY_CONTENTS,
options         IN PLS_INTEGER := 0);
PRAGMA SUPPLEMENTAL_LOG_DATA(registerSchema, UNSUPPORTED_WITH_COMMIT);
TBD
Overload 4 dbms_xmlschema.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   := REGISTER_CSID_NULL,
enableHierarchy IN PLS_INTEGER := ENABLE_HIERARCHY_CONTENTS,
options         IN PLS_INTEGER := 0);
PRAGMA SUPPLEMENTAL_LOG_DATA(registerSchema, UNSUPPORTED_WITH_COMMIT);
TBD
Overload 5 dbms_xmlschema.registerSchema(
schemaURL       IN VARCHAR2,
schemaDoc       IN sys.XMLType,
local           IN BOOLEAN  := TRUE,
genTypes        IN BOOLEAN  := TRUE,
genbean         IN BOOLEAN  := FALSE,
genTables       IN BOOLEAN  := TRUE,
force           IN BOOLEAN  := FALSE,
owner           IN VARCHAR2 := '',
enableHierarchy IN PLS_INTEGER := ENABLE_HIERARCHY_CONTENTS,
options         IN PLS_INTEGER := 0);
PRAGMA SUPPLEMENTAL_LOG_DATA(registerSchema, UNSUPPORTED_WITH_COMMIT);
TBD
Overload 6 dbms_xmlschema.registerSchema(
schemaURL       IN VARCHAR2,
schemaDoc       IN sys.UriType,
local           IN BOOLEAN  := TRUE,
genTypes        IN BOOLEAN  := TRUE,
genbean         IN BOOLEAN  := FALSE,
genTables       IN BOOLEAN  := TRUE,
force           IN BOOLEAN  := FALSE,
owner           IN VARCHAR2 := '',
enableHierarchy IN PLS_INTEGER := ENABLE_HIERARCHY_CONTENTS,
options         IN PLS_INTEGER := 0);
PRAGMA SUPPLEMENTAL_LOG_DATA(registerSchema, UNSUPPORTED_WITH_COMMIT);
TBD
 
REGISTERURI
This function constructs a URIType instance using the URIFactory and invokes the regiserSchema function dbms_xmlschema.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 := '',
enableHierarchy IN PLS_INTEGER := ENABLE_HIERARCHY_CONTENTS,
options         IN PLS_INTEGER := 0);
PRAGMA SUPPLEMENTAL_LOG_DATA(registerURI, UNSUPPORTED_WITH_COMMIT);
TBD

Related Topics
DBMS_METADATA_UTIL
Packages

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2014 Daniel A. Morgan All Rights Reserved