This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 3954 - Indirect circularity of union and restriction should be banned
Summary: Indirect circularity of union and restriction should be banned
Status: RESOLVED FIXED
Alias: None
Product: XML Schema
Classification: Unclassified
Component: Datatypes: XSD Part 2 (show other bugs)
Version: 1.0/1.1 both
Hardware: PC Linux
: P1 normal
Target Milestone: ---
Assignee: C. M. Sperberg-McQueen
QA Contact: XML Schema comments list
URL:
Whiteboard: cluster: cycles
Keywords: needsReview
Depends on:
Blocks:
 
Reported: 2006-11-06 15:52 UTC by Henry S. Thompson
Modified: 2008-05-31 02:55 UTC (History)
0 users

See Also:


Attachments

Description Henry S. Thompson 2006-11-06 15:52:48 UTC
The Sun contribution (about to be published, URI will follow) to the test collection includes the following, which not only makes my head hurt, but sends XSV into an infinite loop:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

        <xsd:simpleType name="abcOrBoolean">
                <xsd:union memberTypes="xsd:boolean abc"/>
        </xsd:simpleType>

        <xsd:simpleType name="abc">
                <xsd:restriction base="abcOrBoolean">
                        <xsd:minLength value="5"/>
                </xsd:restriction>
        </xsd:simpleType>
</xsd:schema>

I believe this manages to escape both the ban on circular unions and the ban on circular derivations, as currently stated.  But it _should_ be banned (and the person who thought of it offered counselling :-)
Comment 1 C. M. Sperberg-McQueen 2007-09-26 01:33:50 UTC
This ties in with bug 3235, which asks where the rule forbidding
circularity of unions is actually imposed.  (Short answer: for now,
only in Structures -- the relevant parts of the two specs do not seem
to be fully aligned.)

I agree that the example (in which a union has a member type derived from 
the union by restriction) should be illegal, and clearly so, both when Structures is used and when it is not.

The rule against cycles is currently formulated twice: once as clause
5 of Simple Type Definition Representation OK
(http://www.w3.org/TR/xmlschema11-1/#src-simple-type):

    5 There are no circular union type definitions. That is, if the
      <union> alternative is chosen, there are no entries in the
      memberTypes [attribute] which ·resolve· to simple types with
      {variety} union which include among their transitive membership
      the component corresponding to the <simpleType>.

and once as clause 3.2 of Derivation Valid (Restriction, Simple)
(http://www.w3.org/TR/xmlschema11-1/#cos-st-restricts)

    3.2 Neither the Simple Type Definition nor a type derived from
        it is a member of its own transitive membership.

Note that the latter of these actually does seem to me to forbid the
pathological example.  But the former gives the misleading impression
that the pathological example is legal.

I think to repair the problem the following should happen:

(1) Clause 5 of Simple Type Definition Representation OK should be
deleted as redundant.  If the WG is unwilling to do that, then
alternatively, add before the full stop the words ", nor any type
definition derived from it".  

(This does touch on the possibly sensitive issue of what purpose the
Schema Representation Constraints are intended to serve, and what
properties should hold for the class of schema documents that satisfy
the Schema Representation Constraints, which means it's important to
get clear on but might turn contentious.)

(2) The alignment of the rules for simple type definitions in
Datatypes and Structures must be worked through again, to ensure that
sanity checks of this kind are expressed in the Datatypes spec.

Because this involves potentially serious issues of design, I am
marking this needsAgreement, to signal the need for discussion by the
Working Group.  The editors can prepare wording, but I don't think a
specific wording proposal is likely to make any difference to the WG
discussion. 
Comment 2 C. M. Sperberg-McQueen 2008-05-30 05:30:17 UTC
A wording proposal intended to resolve this issue is at
http://www.w3.org/XML/Group/2004/06/xmlschema-2/datatypes.b3235.html
(member-only link).
Comment 3 C. M. Sperberg-McQueen 2008-05-31 02:55:00 UTC
The wording proposal in comment #2 was adopted by the WG at today's call.
We believe this resolves the issue, so I am marking it accordingly.

Henry, as the originator of the issue, would you please indicate 
by closing the issue that you are happy with the resolution
(well, satisfied if not happy), or by reopening it that you are not
satisfied?  If we don't hear from you within the next two weeks, we
expect to assume that silence implies consent.