Forum Stats

  • 3,769,419 Users
  • 2,252,962 Discussions
  • 7,875,023 Comments

Discussions

Adding oracle XSD schema annotations to XSD that imports other XSD files

663047
663047 Member Posts: 2
edited Oct 2, 2008 8:51AM in General XML
Hi,

I'm trying to use Oracle XML DB's feature that allows adding annotations to an XSD file so Oracle can create the data model (tables, SQL data types) and link the values to the correct data types. As explained in the documentation here: [http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb05sto.htm#insertedID9]

This works ok, but once i import another XSD file into my main XSD file, I get the following error when registering the schema in oracle with DBMS_XMLSCHEMA.registerSchema:
+"The given schema URL does not refer to a registered XDB schema"+
This error is usually thrown when you forget to add oracle's xdb namespace to the schema. I've added it in my main XSD file, and in the one i am importing.

I'm using Windows server 2003 with Oracle 11g and running my queries trough SQL Developer.
Below you can find code to reproduce the error

main.xsd
-----
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb">
<!-- without this import DBMS_XMLSCHEMA.registerSchema() works ok -->
<xsd:import schemaLocation="import.xsd"/>
</xsd:schema>
-----

import.xsd
-----
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb">
</xsd:schema>
-----

SQL (example for windows, with files in C:/)
-----
CREATE DIRECTORY SCHEMADIR AS 'C:/';
BEGIN
DBMS_XMLSCHEMA.registerSchema('C:/main.xsd', bfilename( 'SCHEMADIR', 'main.xsd' ), TRUE, TRUE, FALSE, TRUE);
END;
-----

Is there any documentation on how to do this? I've found just a small notice in the manual that it -can- be done, but no explanation on how.
Can't find it in the examples either. On one thread i found trough google someone seemed to know how to do this, but didn't bother to explain how.

Thx for anyone that can give me more info on this.
Grts,
Wouter
Tagged:

Answers

  • 663047
    663047 Member Posts: 2
    I've done some more searching and experimenting and found how this has to be done.

    It is implicitly touched upon in the following section:
    [http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb06stt.htm#insertedID9]

    The name used in the XSD file to import another XSD file:
    <xsd:import schemaLocation="import.xsd"/>

    also needs to be used to register the scheme with:
    DBMS_XMLSCHEMA.registerSchema('import.xsd', bfilename( 'SCHEMADIR', 'import.xsd' ), TRUE, TRUE, FALSE, TRUE);

    So:
    1) register the schemas that will be imported using the name as used in the mail xsd file
    2) register the main xsd file

    Obvious... :)
    yet undocumented?
This discussion has been closed.