W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2009

RE: Reg. <all> model group extension

From: bharath <bharathkr@huawei.com>
Date: Tue, 01 Dec 2009 09:57:42 +0530
To: 'Michael Kay' <mike@saxonica.com>, 'Pete Cordell' <petexmldev@codalogic.com>, xmlschema-dev@w3.org
Cc: rajithr@huawei.com, arathikarki@huawei.com, ksrilakshmi@huawei.com
Message-id: <000001ca723e$a050d030$2301120a@china.huawei.com>
Hi Michel Kay,

	Thank you very much for your reply.

Thanks and Regards,

-----Original Message-----
From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On
Behalf Of Michael Kay
Sent: Monday, November 30, 2009 10:06 PM
To: 'bharath'; 'Pete Cordell'; xmlschema-dev@w3.org
Cc: rajithr@huawei.com; arathikarki@huawei.com; ksrilakshmi@huawei.com
Subject: RE: Reg. <all> model group extension

Well, the schema spec is not easy to read: it needs a lot of study to
understand the language it uses. And indeed, it seems my explanation in my
previous email was wrong! Let's take this rule:

[Definition:]  For a particle (call it E, for extension) to be a valid
extension of another particle (call it B, for base)  one of the following
must be true:
1 They are the same particle.
2 E's {min occurs}={max occurs}=1 and its {term} is a sequence group whose
{particles}' first member is a particle all of whose properties,
recursively, are identical to those of B, with the exception of {annotation}

First you need to understand what a particle is. Loosely, it's anything that
appears in a content model but in practice we're only concerned here with
group-level particles (not leaf particles, which are either element
particles or wildcards). A group-level particle is technically referred to
as a "model group", and it has a term which is either a choice group, a
sequence group, or an all group. 

The theory here is that we build the schema components (such as particles)
from the source XSD, and then test whether the components we have built are
valid. (In practice, the processor will usually do these tests while
building the components, and may not even have the capability to build
invalid components). So we first have to see what the rules are for
constructing a complex type component by extension. These are given under
Complex Type Definition with complex content Schema Component in section
3.4.2. Look for the rules for the {content type} property. For both your
complex types, rule 2.2 applies, which means that the effective content is
the particle corresponding to the <all> element; and then rule 3.2.3
applies, which means that the {content type} of the derived type is
effectively the model group:

            <element name="a1" type="string"/>
            <element name="a2" type="string"/>
             <element name="a3" type="string"/>

Now there's a rule in 3.8.6, "Schema Component Constraint: All Group
Limited", which determines whether this model group is actually valid, and
it turns out that it isn't.

The rule says:

When a model group has {compositor} all, then all of the following must be
1 It appears only as the value of one or both of the following properties:
1.1 the {model group} property of a model group definition.
1.2 the {term} property of a particle with {max occurs}=1 which is part of a
pair which constitutes the {content type} of a complex type definition.
2 The {max occurs} of all the particles in the {particles} of the group must
be 0 or 1.

Now here we have two model groups with compositor "all" that appear as part
of a model group with compositor "sequence", which doesn't satisfy either
1.1 or 1.2 (the sequence is not a "model group definition", you only get a
"model group definition" from a <group> element in the schema document.). So
this extended model group isn't valid and therefore the schema isn't valid.

I mentioned the rule Schema Component Constraint: Particle Valid (Extension)
but actually we don't get this far. If we did get this far, the rule would
test whether

            <element name="a1" type="string"/>
            <element name="a2" type="string"/>
             <element name="a3" type="string"/>

was a valid extension of 

      <element name="a1" type="string"/>
      <element name="a2" type="string"/> </all>

and as it happens, if it got past the rule at 3.8.6, then it would be.


Michael Kay
Received on Tuesday, 1 December 2009 04:28:29 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:17 UTC