Re: complexType derivation method

Hi Andrea,

> 1.    when i create a new complexType with complexContent by
> Restriction, can i modify the value of {min occurs} and/or {max
> occurs} of the model group schema components( i.e. <all> , <choice>,
> <sequence>)?

Yes. As long as the {min occurs} of the particle is equal to or more
than the {min occurs} of the equivalent particle in the base
definition, and either the {max occurs} in the base definition is
'unbounded' or the the {max occurs} in the restricted definition is
equal to or less than the {max occurs} of the equivalent particle in
the base definition, then it's fine. So there's no problem with the
example you give.

> 2. extending a complextype using a complexContent:
>
> a. can I extend an <all> with another <all> ? and with a <sequence>
> or with a <choice> ?

No. When you derive by extension, the content model of the derived
type is a sequence - the content model of the base type followed by
the content model you specify as the extension. 'All' model groups are
not allowed within sequences, so extensions from a base type whose
content model contains an 'all' model group (unless its empty or has
one member) are illegal.

> b. can I extend a <choice> with another <choice>? and with a
> <sequence > or with an <all> ?

You can extend a choice with another choice or a sequence, but not an
all for the same reasons as given above. Note that when you extend
with a choice, the two choices are combined in a sequence (the choice
from the base type followed by the choice from the derived type) and
not in a choice (all the particles in one big choice).

> c. can i extend a <sequence> with an <all> or with a <choice>?

You can extend a sequence with a choice, but not an all for the same
reasons as given above.

> 3. I do not understand the meaning of the following sentence from
> XML Schema Part 1: Structures 3.9.6 Constraints on Particle Schema
> Components:
>
> Schema Component Constraint: Particle Valid (Extension) 
>
> [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} properties.
>
> someone may explain to me, with an example, when this constraint is
> applied...and if it is related with my first question.

I do find this one of the more confusing pieces of the Rec :(

This constraint is applied when you create a complex type that is
derived by extension from another complex type. The constraint is
actually called from the Schema Component Constraint: Derivation Valid
(Extension) http://www.w3.org/TR/xmlschema-1/#cos-ct-extends.

When you create a complex type that's derived by extension, the
{content type} of that complex type is defined as a sequence with two
particles - the {content type} from the base type definition, followed
by the content model defined by the content of the xs:complexType
element.

The Particle Valid (Extension) constraint checks this sequence.
Naturally, the sequence must be a valid sequence; it isn't a valid
sequence if it contains an all group, for example. Other than that, it
just checks if the first particle in the sequence is identical to the
{content type} of the base type definition.

When you're creating a schema with XML, then all this constraint
really does is check that the sequence is a valid sequence - you know
that the second clause is going to be true because that's how the
{content type} of the derived type was created in the first place.
This constraint has more impact if the schema is generated in some
other method - the schema components created through some API for
example - where you couldn't make that guarantee.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Friday, 11 January 2002 04:54:01 UTC