« Rule Author and Firefox 3 | Main | Rules from BPEL: Decision Service Usage Patterns Explained (10.1.3) »

Multiple imports or includes in an XML Schema

A common way to modularize a large XML schema is to divide the schema into multiple documents and then "import" or "include" these documents into a primary schema document. For more information on these techniques, see this page.

However, sometimes users will encounter an error like the one below when trying to import it into a dictionary:

[ERROR] src-resolve: Cannot resolve the name 'ns0:Header' to a(n) 'type definition' component. line 13 of baz.xsd

This error indicates that the imported schema has multiple imports with the same namespace. The XML Schema specification says that it's at the discretion of the parser whether or not it wants to acknowledge all of them, and most don't. Xerces is the parser used in WebLogic, and does not. An import has the meaning of "components from namespace X might be found in schema Y," so the parser looks in one of them and then returns that the component cannot be found. The name which the error indicates is in one of the ignored schemas, so the name can't be found.

The most common way around this is to create a schema that includes all of the schemas you want to have in the same namespace, and then import that schema into your primary schema.

Example:
intermediate.xsd:


<schema targetNamespace="foobar" ...>
<include schemaLocation="foo.xsd"/>
<include schemaLocation="bar.xsd"/>
...
</schema>

<schema targetNamespace="baz" ...>
<import namespace="foobar" schemaLocation="intermediate.xsd"/>
...
</schema>

Also, it is common to use <import /> when the target schema has a targetNamespace, and use <include /> when the target schema does not have a targetNamespace.


TrackBack

TrackBack URL for this entry:
http://blogs.oracle.com/mte1521/mt-tb.cgi/8761

Post a comment

About This Entry

This page contains a single entry from the blog posted on December 1, 2008 2:09 PM.

The previous post in this blog was Rule Author and Firefox 3.

The next post in this blog is Rules from BPEL: Decision Service Usage Patterns Explained (10.1.3).

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle