OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] Re: Multiple xsd:imports on the same namespace

[ Lists Home | Date Index | Thread Index ]

Hi David,

> We have been asked to work with some schemas where the definition of
> a namespace is split between several schema documents, each defining
> a subset of the namespace. An example of what I mean is:
>  schemaA.xsd  defines namespaceA, and imports both schemaB.xsd and
>  schemaC.xsd into namespaceB. It then defines an element of each of the
>  types defined in schemas B and C, in namespaceB.
> What do people here think? Can anyone suggest a way of validating
> documents against these schemas?

The general arrangement that you should aim for when using W3C XML
Schema is for each namespace to be defined through a single schema
document and its includes -- i.e. have a single entry point for the
schema information about a particular namespace.

In your case, you could create a single entry point by having a fourth
schema document (schemaD.xsd) which includes both schemaB and schemaC:

<xsd:schema targetNamespace='http://www.example.com/namespaceB'

<xsd:include schemaLocation="schemaB.xsd" />
<xsd:include schemaLocation="schemaC.xsd" />

Then, rather than importing both schemaB and schemaC into schemaA,
just import schemaD instead:

<xsd:schema elementFormDefault='qualified'

  <xsd:import namespace='http://www.example.com/namespaceB'
              schemaLocation='schemaD.xsd' />

  <xsd:element name='Top'>
        <xsd:element name='B' type='nsB:TypeB' />
        <xsd:element name='C' type='nsB:TypeC' />


and things should work fine.



Jeni Tennison


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS