Oracle® Database PL/SQL Packages and Types Reference 10g Release 2 (10.2) Part Number B14258-02 |
|
|
PDF · Mobi · ePub |
DBMS_XMLSCHEMA
package provides procedures to manage XML schemas. It is created by script dbmsxsch.sql
during Oracle database installation.
See Also:
Oracle XML DB Developer's GuideThis chapter contains the following topics:
Overview
Constants
Views
This section contains topics which relate to using the DBMS_XMLSCHEMA
package.
This package provides subprograms to
Register an XML schema
Delete a previously registered XML schema
Re-compile a previously registered XML schema
Generate an XML schema
Evolves an XML schema
The DBMS_XMLSCHEMA
package uses the constants shown in following tables.
Table 130-1 DBMS_XMLSCHEMA Constants - Delete Option
Constant | Type | Value | Description |
---|---|---|---|
|
|
|
Deletion of an XML schema fails if there are any tables or XML schemas that depend on it |
|
|
|
Deletion of an XML schema does not fail if there are tables or XML schemas that depend on it. All dependent tables and schemas are invalidated. |
|
|
|
Deletion of an XML schema also drops all SQL types and default tables associated with it. SQL types are dropped only if |
|
|
|
This option is similar to |
Table 130-2 DBMS_XMLSCHEMA Constants - Enable Hierarchy
Constant | Type | Value | Description |
---|---|---|---|
|
|
|
The |
|
|
|
The |
|
|
|
The |
Table 130-3 DBMS_XMLSCHEMA Constants - Register CSID
Constant | Type | Value | Description |
---|---|---|---|
|
|
|
If a schema is registered for metadata use (using the value |
|
|
|
If user wishes to not specify the character set of the input schema document when invoking |
The DBMS_XMLSCHEMA
package uses the views shown in Table 130-4. The columns of these views are described in detail in the Oracle Database Reference.
Table 130-4 Summary of Views used by DBMS_XMLSCHEMA
Schema | Description |
---|---|
All registered XML Schemas owned by the user |
|
All registered XML Schemas usable by the current user |
|
All registered XML Schemas in the database |
|
All |
|
All |
|
All |
|
All |
|
All |
|
All |
|
All |
|
All |
|
All |
|
All |
|
All |
|
All |
Table 130-5 DBMS_XMLSCHEMA Package Subprograms
Method | Description |
---|---|
Used to re-compile an already registered XML schema. This is useful for bringing a schema in an invalid state to a valid state. |
|
Evolves registered schemas so that existing XML instances remain valid |
|
Removes the schema from the database |
|
Generates the Java bean code corresponding to a registered XML schema |
|
Generates an XML schema from an oracle type name |
|
Generates several XML schemas from an oracle type name |
|
Registers the specified schema for use by Oracle. This schema can then be used to store documents conforming to this. |
|
Registers an XML schema specified by a URI name |
This procedure can be used to re-compile an already registered XML schema. This is useful for bringing a schema in an invalid state to a valid state. Can result in a ORA-31001
exception: invalid resource handle or path name.
DBMS_XMLSCHEMA.COMPILESCHEMA( schemaurl IN VARCHAR2);
Table 130-6 COMPILESCHEMA Procedure Parameters
Parameter | Description |
---|---|
|
URL identifying the schema |
This procedure evolves registered schemas so that existing XML instances remain valid.
This procedure is accomplished in according to the following basic scenario (alternative actions are controlled by the procedure's parameters):
copies data in schema based XMLType
tables to temporary table storage
drops old tables
deletes old schemas
registers new schemas
creates new XMLType
tables
Populates new tables with data in temporary storage; auxiliary structures (constraints, triggers, indexes, and others) are not preserved
drops temporary tables
See Also:
"Schema Evolution" chapter of the Oracle XML DB Developer's Guide for examples on how to evolve existing schemas
Oracle Database Error Messages for information on exceptions specific to schema evolution, ORA-30142 through ORA-30946.
DBMS_XMLSCHEMA.COPYEVOLVE( schemaurls IN XDB$STRUBG_LIST_T, newschemas IN XMLSequenceType, transforms IN XMLSequenceType :=NULL, preserveolddocs IN BOOLEAN :=FALSE, maptablename IN VARCHAR2 :=NULL, generatetables IN BOOLEAN :=TRUE, force IN BOOLEAN :=FALSE, schemaowners IN XDB$STRING_LIST_T :=NULL);
Table 130-7 COPYEVOLVE Procedure Parameters
Parameter | Description |
---|---|
|
|
|
|
|
|
|
Default is |
|
Specifies the name of the table mapping permanent to temporary tables during the evolution process. Valid columns are:
|
|
Default is If
|
|
Default is If |
|
|
You should back up all schemas and documents prior to invocation because COPYEVOLVE Procedure deletes all conforming documents prior to implementing the schema evolution.
This procedure deletes the XML Schema specified by the URL.
DBMS_XMLSCHEMA.DELETESCHEMA( schemaurl IN VARCHAR2, delete_option IN PLS_INTEGER := DELETE_RESTRICT);
See Also:
"XMLSCHEMA Storage and Query: Basic" chapter of the Oracle XML DB Developer's GuideTable 130-8 DELETESCHEMA Procedure Parameters
Parameter | Description |
---|---|
|
URL identifying the schema to be deleted |
Table 130-9 DELETESCHEMA Procedure Exceptions
Exception | Description |
---|---|
|
Invalid resource handle or path name |
This procedure can be used to generate the Java bean code corresponding to a registered XML schema.
DBMS_XMLSCHEMA.GENERATEBEAN( schemaurl IN VARCHAR2);
Table 130-10 GENERATEBEAN Procedure Parameters
Parameter | Description |
---|---|
|
Name identifying a registered XML schema |
Table 130-11 GENERATEBEAN Procedure Exceptions
Exception | Description |
---|---|
|
Invalid resource handle or path name |
Note that there is also an option to generate the beans as part of the registration procedure itself (see the genbean
parameter of the REGISTERSCHEMA Procedures).
This function generates XML schema(s) from an Oracle type name. It inlines all in one schema (XMLType
).
See Also:
"XMLSCHEMA Storage and Query: Advanced" chapter of the Oracle XML DB Developer's GuideDBMS_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;
Table 130-12 GENERATESCHEMA Function Parameters
Parameter | Description |
---|---|
|
Name of the database schema containing the type |
|
Name of the Oracle type |
|
The name of the top level element in the XML Schema. Defaults to |
|
Whether or not to also generate schema for all types referred to by the type specified |
|
Whether or not to put the SQL annotations in the XML Schema |
|
Determines whether the collections should be embedded in the type which refers to them, or create a |
Table 130-13 GENERATESCHEMA Procedure Exceptions
Exception | Description |
---|---|
|
Invalid resource handle or path name |
This function generates XML schema(s) from an Oracle type name. It returns a collection of XMLType
s, one XML Schema document for each database schema.
See Also:
"XMLSCHEMA Storage and Query: Advanced" chapter of the Oracle XML DB Developer's GuideDBMS_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.XMLTYPE;
Table 130-14 GENERATESCHEMAS Procedure Parameters
Parameter | Description |
---|---|
|
Name of the database schema containing the type |
|
Name of the Oracle type |
|
The name of the top level element in the XML Schema defaults to |
|
Specifies base URL where schemas will be stored, needed by top level schema for import statement |
|
Whether or not to put the SQL annotations in the XML Schema |
|
Determines whether the collections be embedded in the type which refers to them, or create a |
Table 130-15 GENERATESCHEMAS Procedure Exceptions
Exception | Description |
---|---|
|
Invalid resource handle or path name |
This procedure registers the specified schema for use by the database. The procedure is overloaded. The different functionality of each form of syntax is presented along with the definition.
See Also:
"XMLSCHEMA Storage and Query: Basic" chapter of the Oracle XML DB Developer's GuideRegisters a schema specified as a VARCHAR2
:
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 := NULL, enablehierarchy IN PLS_INTEGER := DBMS_XMLSCHEMA.ENABLE_CONTENTS, options IN PLS_INTEGER := 0);
Registers the schema specified as a BFILE
. The contents of the schema document must be in the database character set:
DBMS_XMLSCHEMA.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, enablehierarchy IN PLS_INTEGER := DBMS_XMLSCHEMA.ENABLE_CONTENTS, options IN PLS_INTEGER := 0);
Registers the schema specified as a BFILE
and identifies the character set id of the schema document:
DBMS_XMLSCHEMA.REGISTERSCHEMA( schemaurl IN VARCHAR2, schemadoc IN BFILE, local IN BOOLEAN := TRUE, gentypes IN BOOLEAN := TRUE, genbean IN BOOLEAN := TRUE, gentables IN BOOLEAN := TRUE, force IN BOOLEAN := TRUE, owner IN VARCHAR2 := '', csid IN NUMBER, enablehierarchy IN PLS_INTEGER := DBMS_XMLSCHEMA.ENABLE_CONTENTS, options IN PLS_INTEGER := 0);
Registers the schema specified as a BLOB
. The contents of the schema document must be in the database character set:
DBMS_XMLSCHEMA.REGISTERSCHEMA( schemaurl IN VARCHAR2, schemadoc IN BLOB, local IN BOOLEAN := TRUE, genTypes IN BOOLEAN := TRUE, genBean IN BOOLEAN := FASLE, force IN BOOLEAN := FALSE, owner IN VARCHAR2 := NULL, enablehierarchy IN PLS_INTEGER := DBMS_XMLSCHEMA.ENABLE_CONTENTS, options IN PLS_INTEGER := 0);
Registers the schema specified as a BLOB
and identifies the character set id of the schema document:
DBMS_XMLSCHEMA.REGISTERSCHEMA( schemaurl IN VARCHAR2, schemadoc IN BLOB, local IN BOOLEAN := TRUE, gentypes IN BOOLEAN := TRUE, genbean IN BOOLEAN := TRUE, gentables IN BOOLEAN := TRUE, force IN BOOLEAN := TRUE, owner IN VARCHAR2 := '', csid IN NUMBER, enablehierarchy IN PLS_INTEGER := DBMS_XMLSCHEMA.ENABLE_CONTENTS, options IN PLS_INTEGER := 0);
Registers the schema specified as a CLOB
DBMS_XMLSCHEMA.REGISTERSCHEMA( schemaurl IN VARCHAR2, schemadoc IN CLOB, local IN BOOLEAN := TRUE, gentypes IN BOOLEAN := TRUE, genbean IN BOOLEAN := FALSE, force IN BOOLEAN := FALSE, owner IN VARCHAR2 := NULL, options IN PLS_INTEGER := 0);
Registers the schema specified as an XMLTYPE
.
DBMS_XMLSCHEMA.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, enablehierarchy IN PLS_INTEGER := DBMS_XMLSCHEMA.ENABLE_CONTENTS, options IN PLS_INTEGER := 0);
Registers the schema specified as a BLOB
. The contents of the schema document must be in the database character set:
DBMS_XMLSCHEMA.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, enablehierarchy IN PLS_INTEGER := DBMS_XMLSCHEMA.ENABLE_CONTENTS, options IN PLS_INTEGER := 0);
Table 130-16 REGSITERSCHEMA Procedure Parameters
Parameter | Description |
---|---|
|
URL that uniquely identifies the schema document. This value is used to derive the path name of the schema document within the database hierarchy. Can be used inside |
|
A valid XML schema document |
|
Is this a local or global schema?
You need write privileges on the directory to be able to register a schema as global. |
|
Determines whether the schema compiler generates object types. By default, |
|
Determines whether the schema compiler generates Java beans. By default, |
|
Determines whether the schema compiler generates default tables. By default, |
|
If this parameter is set to |
|
This parameter specifies the name of the database user owning the XML schema object. By default, the user registering the schema owns the XML schema object. This parameter can be used to register a XML schema to be owned by a different database user. |
|
Identifies the character set of the input schema document. If this value is |
|
|
|
Additional options to specify how the schema should be registered. The various options are represented as bits of an integer and the options parameter should be constructed by doing a
|
This procedure registers an XML Schema specified by a URI name.
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 := NULL, options IN PLS_INTEGER := 0);
Table 130-17 REGISTERURI Procedure Parameters
Parameter | Description |
---|---|
|
Uniquely identifies the schema document. Can be used inside |
|
Pathname (URI) corresponding to the physical location of the schema document. The URI path could be based on HTTP, FTP, DB or Oracle XML DB protocols. This function constructs a |
|
Determines whether this is a local or global schema. By default, all schemas are registered as local schemas, under |
|
Determines whether the compiler generate object types. By default, |
|
Determines whether the compiler generate Java beans. By default, |
|
Determines whether the compiler generate default tables. |
|
|
|
This parameter specifies the name of the database user owning the XML schema object. By default, the user registering the schema owns the XML schema object. This parameter can be used to register a XML schema to be owned by a different database user. |
|
Additional options to specify how the schema should be registered. The various options are represented as bits of an integer and the options parameter should be constructed by doing a
|