Generating an Annotated Schema for Oracle

Oracle 9i2 is a database server with a native XML storage and retrieval technology called Oracle XML DB. There is no mapping between XML data and relational data. Tables, columns and abstract data types (ADT) are created from annotated schemas (XSDs). Annotated schemas are XML-coded files, targeted with an XML language and tagged with specific DBMS annotations, that allow you to store or retrieve data in an XML format, from relational databases supporting XML.

An XML model allows you to generate an annotated schema (XSD) for Oracle 9i2. Oracle 9i2 uses by default the name of the XML elements present in the annotated schema to generate SQL objects. You can override the creation of SQL objects by defining extended attributes for elements, complex types and the XML model.

  1. To enable the Oracle extensions in your model, select Model > Extensions, click the Import tool, select the Oracle XML DB (on the XML in Database tab), and click OK to attach it.
  2. [optional] Specify the following properties on the Extended Attributes tab of the property sheets of elements:

    Annotation

    Description

    beanClassname

    Can be used within element declarations. If the element is based on a global complexType, this name must be identical to the beanClassname value within the complexType declaration. If a name is specified by the user, the bean generation will generate a bean class with this name, instead of generating a name from the element name

    columnProps

    Specifies the column storage clause that is inserted into the default CREATE TABLE statement. It is useful mainly for elements that are mapped to tables, namely top-level element declarations and out-of-line element declarations

    defaultTable

    Specifies the name of the table into which XML instances of this schema should be stored. This is most useful in cases when the XML is being inserted from APIs where table name is not specified (for example, FTP and HTTP)

    javaClassname

    Used to specify the name of a Java class that is derived from the corresponding bean class, to ensure that an object of this class is instantiated during bean access. If a JavaClassname is not specified, Oracle XML DB will instantiate an object of the bean class directly

    maintainDOM

    If true, instances of this element are stored so that they retain DOM fidelity on output. This implies that all comments, processing instructions, namespace declarations, and so on, are retained in addition to the ordering of elements. If false, the output need not be guaranteed to have the same DOM behavior as the input

    maintainOrder

    If true, the collection is mapped to a VARRAY. If false, the collection is mapped to a NESTED TABLE

    SQLCollSchema

    Name of the database user owning the type specified by SQLCollType

    SQLCollType

    Specifies the name of the SQL collection type corresponding to this XML element that has maxOccurs > 1

    SQLInline

    If true this element is stored inline as an embedded attribute (or a collection if maxOccurs > 1). If false, a REF (or collection of REFs if maxOccurs > 1) is stored. This attribute will be forced to false in certain situations (like cyclic references) where SQL will not support inlining

    SQLName

    Specifies the name of the attribute within the SQL object that maps to this XML element

    SQLSchema

    Name of the database user owning the type specified by SQLType

    SQLType

    Specifies the name of the SQL type corresponding to this XML element declaration

    tableProps

    Specifies the TABLE storage clause that is appended to the default CREATE TABLE statement. This is meaningful mainly for global and out-of-line elements

  3. [optional] Specify the following properties on the Extended Attributes tab of the property sheets of complex types:

    Annotation

    Description

    beanClassname

    Can be used within element declarations. If the element is based on a global complexType, this name must be identical to the beanClassname value within the complexType declaration. If a name is specified by the user, the bean generation will generate a bean class with this name, instead of generating a name from the element name

    SQLSchema

    Name of the database user owning the type specified by SQLType

    SQLType

    Specifies the name of the SQL type corresponding to this XML element declaration

  4. [optional] Specify the following properties on the Extended Attributes tab of the property sheets of the model:

    Annotation

    Description

    mapUnboundedStringToLob

    If true, unbounded strings are mapped to CLOB by default. Similarly, unbounded binary data get mapped to BLOB, by default. If false, unbounded strings are mapped to VARCHAR2(4000), and unbounded binary components are mapped to RAW(2000)

    storeVarrayAsTable

    If true, the VARRAY is stored as a table (OCT). If false, the VARRAY is stored in a LOB

  5. Select Language > Generate schema File to open the Generation dialog box.
  6. Specify the directory in which to generate the file and select the XML in Database target on the Targets tab.


  7. Click OK to begin the generation.

    The Result dialog box is displayed with the path of the annotated schema file selected.

  8. Click Edit to open the generated annotated schema in your associated editor:


    Note the Oracle namespace (with the sql prefix) and annotations for tables (sql:SQLName) and ADTs (sql:SQLType)