Re: multiply-connected graph of schema import

On 4/18/2011 11:42 AM, C. M. Sperberg-McQueen wrote:
> On Apr 18, 2011, at 1:52 AM, Paul Harrison wrote:
>
>> Is a multiply-connected (but non-circular) graph of schema imports allowed by the standard?
>>
>> e.g  B imports A
>>       C imports B
>>       D imports C and A
>>
>>
>> The intention is that schema D extends types that appear in schemas C and A. There seems to be some confusion in various tools as to what is needed - it seems that some tools require the explicit import of schema A if D makes an explicit extension of a type in schema A, but other tools will report that the types in A have been defined twice it this explicit import is made.
>>
>> I would like a opinion on what should be happening according to the standards, so that I can complain to one of the schema tool writers that I am using.....
>
> For some tools, the result will depend on which schema
> document you start with and/or the order in which various
> inclusions, imports, or schemaLocation hints occur in the
> relevant schema document.
>
> The treatment of schema composition is cloudy enough in
> both XSD 1.0 that it's very difficult to make a conclusive
> case for, or against, any particular behavior as being
> clearly required or clearly non-conforming.  And unfortunately
> the WG has been too deeply divided to be able to do anything
> to clear things up in XSD 1.1.  (When shown an example
> in which five different implementations produced eight
> different behaviors, depending on how they were invoked,
> one WG member seriously argued that it really wasn't an
> issue, because the spec does not try to specify any rules for
> how command-line invocation is handled.  The chair
> ruled, not unreasonably, that there was really no prospect
> of reaching consensus on any change in the rules for
> schema composition.)
>

It is probably worth noting that two issues come into play with 
<import>: 1) making it legal to reference a namespace and 2) locating 
referenced components from the imported namespace.  Note that:

- XSD requires that when you reference components from another 
namespace, you must import that namespace in the document where the 
reference occurs (see rule 4.2.2 in section 
http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structures.html#src-resolve)

- XSD allows for multiple importing of the same schema document.  It 
says, "The above is carefully worded so that multiple <import> 
<http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structures.html#element-import>ing 
of the same schema document will not constitute a violation of clause 2 
<http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structures.html#c-nmd> 
of Schema Properties Correct (§3.15.6) 
<http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structures.html#sch-props-correct>".

As far as actually locating the definitions of referenced components is 
concerned, XSD is less precise.

Assuming each of your documents has a distinct namespace, then I believe 
in document D you must <import> namespace A, but XSD does not require 
you to refer to document A in the schemaLocation attribute of that 
<import>.  It sounds like the error you are getting regarding duplicate 
definitions is incorrect, though, given what I quoted above.

Kevin
-- 
Objective Systems, Inc.
REAL WORLD ASN.1 AND XML SOLUTIONS
http://www.obj-sys.com

Received on Monday, 18 April 2011 16:28:08 UTC