This content has been marked as final. Show 6 replies
The SchemaURL parameter simply provides a unique identifier for each XML Schema registered in a particular database schema. By convention the schemaURL is typically given in the form of a URL, but this is not mandatory, In the cases where the schemaURL is a valid URL XML DB does not need to be able to access the URL in order to register the XML Schema.
The schemaURL supplied to registerSchema must be an exact match for the "Schema Location Hint" in any instance documents that are going to be loaded into the database using protocols or DBMS_XDB.createResource().
The names of objects (Tables, Types, Type attributes) created by the schema registration processes are derived from the names of the objects in the XML Schema. Since XML Schema uses mixed case naming, the names of the Tables, Types and Type Attibtues are also created with mixed case names. This means that you must enclose the names of these objects in quotes when accessing them in SQL as the following example demonstates.
You can also force explicit uppercase names for these items by annotating the XML Schema. Use xdb:SQLName to specify the name of Type Attributes, xdb:defaultTable to specify the name of Tables and xdb:SQLType to specify the name of SQLTypes.
SQL> select table_name from user_xml_tables 2 where xmlschema = :schemaUrl 3 / TABLE_NAME ------------------------------ PurchaseOrder348_TAB SQL> desc PurchaseOrder348_TAB ERROR: ORA-04043: object PurchaseOrder348_TAB does not exist SQL> desc "PurchaseOrder348_TAB" Name Null? Type ----------------------------------------- -------- ---------------------------- TABLE of SYS.XMLTYPE(XMLSchema "PurchaseOrder.xsd" Element "PurchaseOrder") STORAGE Object-relational TYPE "PurchaseOrderType347_T" SQL> desc PurchaseOrderType347_T ERROR: ORA-04043: object PurchaseOrderType347_T does not exist SQL> desc "PurchaseOrderType347_T" "PurchaseOrderType347_T" is NOT FINAL Name Null? Type ----------------------------------------- -------- ---------------------------- SYS_XDBPD$ XDB.XDB$RAW_LIST_T Reference VARCHAR2(30 CHAR) Actions ActionsType340_T Reject RejectionType339_T Requestor VARCHAR2(128 CHAR) User VARCHAR2(10 CHAR) CostCenter VARCHAR2(4 CHAR) ShippingInstructions ShippingInstructionsTyp338_T SpecialInstructions VARCHAR2(2048 CHAR) LineItems LineItemsType345_T SQL>
When a Schema-based XML document is loaded in the Oracle XML DB repository the content of the document can be stored in one of two places.
If the document is correctly associated with an XML Schema then the content of the document will stored in the default table defined by the XML Schema. If the document is not associated with an XML schema then the content of the document will stored in the database schema owned by the XDB user.
You can tell whether or not a document has been recognized as being associated with an XML schema by looking at the size of the document using WebDAV or FTP. If the size of the document is reported as 0 bytes then the content of the document has been stored in the default table. If the size of the document is reported as non-zero then the document has not been associated with an XML Schema. Note that when using WebDAV to view the size of the file the a newly loaded file may appear with a non-zero size until the contents of the folder are refreshed.
When a file is loaded into the repository via the FTP, HTTP or WebDAV protcols of a resource is created using DBMS_XDB.createResource() XML DB peeks into the content of the document.
If the content of the file is not recognized as XML the document is stored in the database schema owned by the XDB user.
If the file contains XML, XML DB looks at the root tag of the document to see if includes either a schemaLocation attribute or a noNamespaceSchemaLocation attribute in the W3C XMLSchema-Instance namespace.
If the root tag does not contain these attributes then the document is stored as non schema based XML. The content will stored in the database schema owned by the XDB user.
If the XML document contains a schemaLocation attribute or a noNamespaceSchemaLocation attribute XML DB attempts to match the document against the list of registered XML Schemas available to the user uploading the document.
If a match is found XML DB next matches the root element of the document againt the set of global elements defined by the XML schema and and uses the value of the xdb:defaultTable and xdb:defaultTableSchema attributes to determine which table the content should be stored in.
If XML DB is unable to match the document against the list of known XML schemas the content of the document is stored in the database schema owned by the XDB user.
There are two reasons why the content of a Schema Based XML document is not accessable via deafult table. The first is that the document is protected with an ACL that forbids the user searching for the document from seeing it. The second is that the document was not recognized as being a member of the class defined by the XML Schema and so was stored as non-schema-based in the XML DB repository rather than as schema based XML in the default table.
The methodolgy used by XML DB to match instance documents to XML schemas is based on a mechansim defined by the W3C XML schema standard. The W3C standard uses the XMLSchema-instance namespace to add schema specific information to instance documents.
The XMLSchema-instance namespace defines two attibutes that can be used to identify which XML Schema a document is associated with. These attributes are the noNamespaceSchemaLocation attribute and the schemaLocation attribute.
The noNamespaceSchemaLocation attribute is used in conjunction with XML Schemas that do not include a targetNamespace declaration. The schemaLocation attribute is used in conjunction with XML Schemas that declare a targetNamespace
The noNamspaceSchemaLocation attribute is used to supply the Schema Location Hint of the XML schema the document is associated with. For XML DB to recognize that the document is a member of the class defined the XML schema the Schema Location Hint must be an exact for the schemaURL that was used tor register the XML schema with XML DB.
The schemaLocation attribute is used to supply a Schema Location Hint for each namespace used by the instance document. The attribute consists of a set of namespace location mappings. A namespace location mapping consists of a namespace and the Schema Location Hint for the XML Schema that declares that namespace.
An XML Document is considered to be instance of the XML schema if the Schema Location Hint matches the URL of a registered XML Schema that declares the namespace associated with the Schema Location Hint as it's targetNamespace.
First, the instance document must declare the XMLSchema-instance namespace
The XMLSchema-instance namespace is used to associated the XML document with an XML schema. It does by supplying a "Schema Location Hint" for the target XML schema. The Schema Location Hint is typically the authoritive location for the XML Schema. When using XML DB the Schema Location Hint must match the URL used to register the XML schema with XML DB when working with XML DB.
The manner is which the schema location hint is supplied depends on hether or not the xml schema contains a targetNamespace declaration
If a targetNamespace is defined then it the instance must include the schemaLocation attribute. The schemaLocation attribute must contain a mapping between the targetNamespace and the Schema Location Hint in the form "namespace schemaLocationHint".
If the XML schema declares a target namespace such as targetNamespace="http://www.opengis.net/examples/packet" and the Schema Location Hint is "gmlpacket.xsd" then you use the schemaLocation attribute. It will look like this.
If the XML schema does not declare a target namespace then you the noNamespaceSchemaLocation attribute. It will look like this..