Oracle DBMS_XMLSCHEMA
Version 12.2.0.1

General Information
Library Note Morgan's Library Page Header
"I spent my entire adult life looking out for the well-being, the training, the equipping of the troops for whom I was responsible. I will not be lectured about what our military needs by a five-deferment draft dodger,"
~ Sen. Tammy Duckworth
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 KU$_M_VIEW_PFH_VIEW KU$_VIEW_VIEW
DBMS_METADATA_HACK KU$_M_VIEW_PIOT_VIEW KU$_XMLSCHEMA_ELMT_VIEW
DBMS_METADATA_UTIL KU$_M_ZONEMAP_FH_VIEW KU$_ZM_VIEW_FH_VIEW
DBMS_REGXDB KU$_M_ZONEMAP_IOT_VIEW KU$_ZM_VIEW_IOT_VIEW
DBMS_XMLSCHEMA_INT KU$_M_ZONEMAP_PFH_VIEW KU$_ZM_VIEW_PFH_VIEW
KU$_10_1_FHTABLE_VIEW KU$_M_ZONEMAP_PIOT_VIEW KU$_ZM_VIEW_PIOT_VIEW
KU$_10_1_IOTABLE_VIEW KU$_NT_PARENT_VIEW NLS_DATABASE_PARAMETERS
KU$_10_1_PFHTABLE_VIEW KU$_OPQTYPE_VIEW PLITBLM
KU$_10_1_PIOTABLE_VIEW KU$_P2TCOLUMN_VIEW SDO_CSWADM
KU$_10_2_FHTABLE_VIEW KU$_P2TPARTCOL_VIEW URIFACTORY
KU$_11_2_VIEW_VIEW KU$_PARTITION_VIEW URITYPE
KU$_ACPTABLE_VIEW KU$_PCOLUMN_VIEW XDB$ELEMENT
KU$_CLUSTER_VIEW KU$_PFHTABLE_VIEW XDB$INCLUDE_LIST_T
KU$_COLUMN_VIEW KU$_PIOTABLE_VIEW XDB$INCLUDE_T
KU$_FHTABLE_VIEW KU$_QTAB_STORAGE_VIEW XDB$SCHEMA
KU$_IOTABLE_VIEW KU$_QUEUE_TABLE_VIEW XDB$STRING_LIST_T
KU$_M_VIEW_FH_VIEW KU$_SP2TCOLUMN_VIEW XMLSCHEMA_LIB
KU$_M_VIEW_IOT_VIEW KU$_SP2TPARTCOL_VIEW XMLSEQUENCETYPE
KU$_M_VIEW_LOG_FH_VIEW KU$_SUBPARTITION_VIEW XMLTYPE
KU$_M_VIEW_LOG_PFH_VIEW    
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      IN VARCHAR2,
xmltypename IN 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      IN VARCHAR2,
xmltypename IN 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
Built-in Functions
Built-in Packages
DBMS_METADATA_UTIL
DBMS_XMLSCHEMA_LSB
What's New In 12cR1
What's New In 12cR2

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-2017 Daniel A. Morgan All Rights Reserved