We have seen some schemas where the definition of a namespace is split
between several schemas, each defining a subset of the namespace. An
example of what I mean is attached:

 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.

This generates errors on validation.

It appears that xerces ignores the second import, so the type defined in
schemaC.xsd is not available when it is used to define the element.

XMLspy, however accepts this use, and validates the instance fine. Also,
the IBM XML Schema quality checker[3], claims there is no error in
schemaA.xsd.

As schemas and namespaces get larger, and more complicated, I expect
this sort of separation to become more and more widespread. 

I think that where we are having trouble, is with the following extract
from [1]:

   Given that the schemaLocation [attribute] is only a hint, it is open
   to applications to ignore all but the first <import> for a given
   namespace, regardless of the �actual value� of schemaLocation, but
   such a strategy risks missing useful information when new
   schemaLocations are offered.
   
Ignoring the second one seems to be allowed. It is also stated to be
implementation dependent in [2], however I believe that supporting this
use case is something we should do.

That said, it could prove difficuult to stop ignoring subsequent imports
for a namespace, as it opens up the problem of duplicate imports, and
circular imports.

Should I bug report this, or does it need discussing first?

David

[1] http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-import
[2] http://lists.w3.org/Archives/Public/www-xml-schema-comments/2000OctDec/0480.html
[3] http://www.alphaworks.ibm.com/tech/xmlsqc
-- 
David Sheldon, Client Services        DecisionSoft Ltd.
Telephone: +44-1865-203192            http://www.decisionsoft.com
<Top xmlns="http://www.example.com/namespaceA"; xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='schemaA.xsd'>
  <B>12345</B>
  <C>AAAAA</C>
</Top>
<?xml version="1.0" encoding="UTF-8" ?>

<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='schemaB.xsd' />
  <xsd:import namespace='http://www.example.com/namespaceB' 
schemaLocation='schemaC.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>
<?xml version="1.0" encoding="UTF-8" ?>

<xsd:schema elementFormDefault='qualified' attributeFormDefault='unqualified' 
targetNamespace='http://www.example.com/namespaceB' 
xmlns='http://www.example.com/namespaceB' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
  <xsd:simpleType name='TypeB'>
    <xsd:restriction base='xsd:string'>
      <xsd:pattern value='[0-9]{5}' />
    </xsd:restriction>
  </xsd:simpleType>
</xsd:schema>
<?xml version="1.0" encoding="UTF-8" ?>

<xsd:schema elementFormDefault='qualified' attributeFormDefault='unqualified' 
targetNamespace='http://www.example.com/namespaceB' 
xmlns='http://www.example.com/namespaceB' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
  <xsd:simpleType name='TypeC'>
    <xsd:restriction base='xsd:string'>
      <xsd:pattern value='A{5}' />
    </xsd:restriction>
  </xsd:simpleType>
</xsd:schema>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to