- From: C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>
- Date: Fri, 15 Apr 2011 09:52:21 -0600
- To: xmlschema-dev@w3.org
- Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, Michael Kay <mike@saxonica.com>
On Apr 15, 2011, at 4:57 AM, Michael Kay wrote: > On 14/04/2011 14:15, Paul Harrison wrote: >> Is a multiply-connected (but non-circular) graph of schema imports allowed? >> >> e.g B imports A >> C imports B >> D imports C and A >> >> Some tools seem to get a little confused by this sort of thing >> >> Regards, >> Paul >> >> > It's not only allowed, it's often essential. > > The rule is that if a schema document A references a schema component in namespace N, then it must include an xs:import for namespace N. > > It's true however that the rules in the spec leave a lot to be desired (XSD 1.1 improves them, though not as much as I would like), and as a result, implementations are not 100% consistent. > > xs:include is different - there's never a need to have circular includes, but they certainly shouldn't cause any problems if you do. 'Should' may be a key word in that last sentence; "shouldn't" cause problems is not the same as "won't" cause problems. The text of 1.0 defines inclusion in terms of 'the schema corresponding to' the included schema document, and its effect on 'the schema corresponding to' the including schema document. So if A includes B, we can know what schema corresponds to A only by first calculating the schema corresponding to B. In the case of circular includes, the schema corresponding to Be can be calculated only by first calculating the schema corresponding to A. But we do not yet know what that is, because we have not yet calculated all the things it depends on. We have infinite regress, caused by a recursive definition that identifies no base case. The most natural implementation of this definition is to turn the circular case into an infinite loop, and that is in fact what some implementations have done. Other implementations of XSD 1.0 have taken the view that circular includes are legal and have a well defined meaning, but I do not know how they derive that conclusion from the text of the spec, and in fact I do not believe they can. When I have asked implementors about it, the answer has usually amounted to a shrug; it has never involved any appeal at all to the actual words of the spec. So while some 1.0 processors will process circular includes without complaint, schema authors interested in having their schema documents work with more than one 1.0 processor would be wise to avoid circular includes. In 1.1, an explicit rule is added to justify stopping the recursion. But I think that was a substantive not an editorial change. -- **************************************************************** * C. M. Sperberg-McQueen, Black Mesa Technologies LLC * http://www.blackmesatech.com * http://cmsmcq.com/mib * http://balisage.net ****************************************************************
Received on Friday, 15 April 2011 15:52:49 UTC