Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

CreateSchemaBasedXML using multiple schemas

1030777Aug 5 2013 — edited Aug 6 2013

I am trying to perform XSD validation against an XML document within PLSQL and I'm having an issue with getting it working. 

I have created an XMLTYPE object, which when I call isSchemaBased() against it returns 0 (false). Now obviously the XMLTYPE needs to be schema based in order to be validated, I found that you can make a schema based version by calling createSchemaBasedXML against the XMLTYPE. The problem I am having is that my schema is broken into two parts (combining the schema files is not an option unfortunately), which means that when I try and createSchemaBasedXML specifying the main schema it fails because it is unable to resolve a reference which is imported from the second XSD document.

-- lxml is the XMLTYPE which has been populated with the XML before this point

dbms_xmlschema
.registerSchema(
  schemaURL
=> mainSchemaURL,
  schemaDoc
=> mainSchemaDoc,
  local
=> true,
  genTypes
=> true,
  genTables
=> false,
  force
=> true,
  enableHierarchy
=> dbms_xmlschema.ENABLE_HIERARCHY_NONE);

dbms_xmlschema
.registerSchema(
  schemaURL
=> importedSchemaURL,
  schemaDoc
=> importedSchemaDoc,
  local
=> true,
  genTypes
=> true,
  genTables
=> false,
  force
=> true,
  enableHierarchy
=> dbms_xmlschema.ENABLE_HIERARCHY_NONE);

if lxml.isSchemaBased() = 1 then
  dbms_output
.put_line('Schema based');
else
  dbms_output
.put_line('Non-schema based');
end if;

dbms_ouput
.put_line('About to apply schema');
lxml
:= lxml.createSchemaBasedXML(mainSchemaURL);
dbms_ouput
.put_line('We don't get this far');

lxml
:= lxml.createSchemaBasedXML(importedSchemaURL);
 

Is there any way of being able to import both the mainSchemaURL and the importedSchemaURL at the same time so that the imported schema references within the main schema don't cause the failure;

ORA-31079: unable to result reference to type [type containing imported type]

Any help or pointers would be greatly appreciated.

This post has been answered by odie_63 on Aug 5 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 3 2013
Added on Aug 5 2013
4 comments
3,140 views