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.
>
[snip]
> 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'
            xmlns='http://www.example.com/namespaceB'
            xmlns:xsd='http://www.w3.org/2001/XMLSchema'>

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

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

<xsd:schema elementFormDefault='qualified'
            attributeFormDefault='unqualified'
            targetNamespace='http://www.example.com/namespaceA'
            xmlns='http://www.example.com/namespaceA'
            xmlns:xsd='http://www.w3.org/2001/XMLSchema'
            xmlns:nsB='http://www.example.com/namespaceB'>

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

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

</xsd:schema>

and things should work fine.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/





 

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

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