René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Schema annotations for XML DB

begin
  dbms_xmlschema.registerSchema(
  'some_dummy_url',
  '
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:xdb="http://xmlns.oracle.com/xdb"
            version  ="1.0" xdb:storeVarrayAsTable="true">

   <xsd:element name="Employee" xdb:defaultTable="PERSON">
     <xsd:complexType           xdb:SQLType     ="PERSON_T">
       <xsd:sequence>
         <xsd:element name="FirstName"  minOccurs="1" xdb:SQLName="FN"                               />
         <xsd:element name="MiddleName" minOccurs="0" xdb:SQLName="MN"                               />
         <xsd:element name="LastName"   minOccurs="1" xdb:SQLName="LN"                               />
       </xsd:sequence>
       <xsd:attribute name="EmployeeID" type="xsd:integer" xdb:SQLName="EID" xdb:SQLType="NUMBER"    />
     </xsd:complexType>
   </xsd:element>
</xsd:schema>
  ',
  true,   -- local
  true,   -- schema compiler will generate object types
  false,  -- don't generate java beans
  false   -- don't allow invalid schemas
);
end;
/
When this block is run, a type named PERSON_T is created:
SQL> desc person_t
 Name                                                  Null?    Type
 ----------------------------------------------------- -------- -----------------------------------
 SYS_XDBPD$                                                     XDB.XDB$RAW_LIST_T
 EID                                                            NUMBER(38)
 FN                                                             VARCHAR2(4000 CHAR)
 MN                                                             VARCHAR2(4000 CHAR)
 LN                                                             VARCHAR2(4000 CHAR)

defaultTable

Specifies the name of the default table that is generated for each global element when gentables is set to false.

SQLName

Names the attribute that corresponds to elements and attributes in the registered schema.

SQLType

Names the generated type for complex type definitions.

SQLCollType

Names the VARRAY type that manages collections of elements.

MaintainDOM

storeVarrayAsTable