- From: Dare Obasanjo <dareo@microsoft.com>
- Date: Tue, 25 Feb 2003 15:51:27 -0800
- To: <xmlschema-dev@w3.org>
Is the following restriction valid: BASE: <xs:sequence minOccurs="0" maxOccurs="1"> <xs:any namespace="##any" processContents="skip" minOccurs="1" maxOccurs="unbounded"/> </xs:sequence> DERIVED: <xs:sequence minOccurs="0" maxOccurs="1"> <xs:element name="A" minOccurs="1" maxOccurs="unbounded" /> <xs:element name="B" minOccurs="1" maxOccurs="unbounded" /> </xs:sequence> The Microsoft schema validators consider it an invalid derivation for the following reasons (which we'd be interested in hearing counter arguments to): The schema author is trying to restrict a sequence containing a single particle to one containing multiple particles. The definition for a particle is given below taken from the W3C XML Schema recommendation at http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#cParticles "The particle schema component has the following properties: Schema Component: Particle {min occurs} A non-negative integer. {max occurs} Either a non-negative integer or unbounded. {term} One of a model group, a wildcard, or an element declaration. In general, multiple element information item [children], possibly with intervening character [children] if the content type is mixed, can be ·validated· with respect to a single particle. When the {term} is an element declaration or wildcard, {min occurs} determines the minimum number of such element [children] that can occur. The number of such children must be greater than or equal to {min occurs}. If {min occurs} is 0, then occurrence of such children is optional." The base type consists of a sequence containing a single particle with a {min occurs} of 0, a {max occurs} of unbounded and whose {term} is a wildcard. <xs:sequence minOccurs="0" maxOccurs="1"> <xs:any namespace="##any" processContents="skip" minOccurs="1" maxOccurs="unbounded"/> </xs:sequence> The derived type consists of a sequence containing two particles. Both particles have a {min occurs} of 0, a {max occurs} of unbounded and a {term} which is an element declaration. <xs:sequence minOccurs="0" maxOccurs="1"> <xs:element name="A" minOccurs="1" maxOccurs="unbounded" /> <xs:element name="B" minOccurs="1" maxOccurs="unbounded" /> </xs:sequence> According to the rules for derivation by restriction of one sequence from another at http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#rcase-Recurse "For an all or sequence group particle to be a ·valid restriction· of another group particle with the same {compositor} all of the following must be true: 1 R's occurrence range is a valid restriction of B's occurrence range as defined by Occurrence Range OK (§3.9.6). 2 There is a complete ·order-preserving· functional mapping from the particles in the {particles} of R to the particles in the {particles} of B such that all of the following must be true: 2.1 Each particle in the {particles} of R is a ·valid restriction· of the particle in the {particles} of B it maps to as defined by Particle Valid (Restriction) (§3.9.6). 2.2 All particles in the {particles} of B which are not mapped to by any particle in the {particles} of R are ·emptiable· as defined by Particle Emptiable (§3.9.6). NOTE: Although the ·validation· semantics of an all group does not depend on the order of its particles, derived all groups are required to match the order of their base in order to simplify checking that the derivation is OK. [Definition:] A complete functional mapping is order-preserving if each particle r in the domain R maps to a particle b in the range B which follows (not necessarily immediately) the particle in the range B mapped to by the predecessor of r, if any, where "predecessor" and "follows" are defined with respect to the order of the lists which constitute R and B. " The key statement to note is that the 'there is a complete order preserving functional mapping from the particles in the {particles} of R to the particles in the {particles} of B'. When trying to map a single particle with a wildcard term to two particles with element terms, this is not the case. Why this is necessary is made clearer in a simplified example. Consider the following base type <xs:sequence minOccurs="0" maxOccurs="1"> <xs:any namespace="##any" processContents="skip" minOccurs="1" maxOccurs="1"/> </xs:sequence> which one tries to derive from with the following <xs:sequence minOccurs="0" maxOccurs="1"> <xs:element name="Element1" minOccurs="1" maxOccurs="1" type="xs:string"/> <xs:element name="Element2" minOccurs="1" maxOccurs="1" type="xs:string"/> </xs:sequence> In the above case it is clear that the derived type is not a restriction of the base type. The same rules used to determine that the above case is invalid are the same ones used to declare the original attempt at derivation to be invalid. -- PITHY WORDS OF WISDOM Drive defensively--buy a tank. This posting is provided "AS IS" with no warranties, and confers no rights.
Received on Tuesday, 25 February 2003 18:52:00 UTC