- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Wed, 1 May 2002 09:39:27 +0100
- To: Simon.Cox@csiro.au
- CC: xmlschema-dev@w3.org, rmartell@galdosinc.com
Hi Simon,
> So Jeni, given that the constraint we quoted below states:
>
> "B's {variety} is union and D is ***validly derived from***
> a type definition in B's {member type definitions}
> given the subset, as defined by this constraint."
>
> then D could even be an *extension* of one of the member types? For
> example, is the following also valid (seems like a stretch...)?
>
> <element name="_duration" type="gml:TMDurationType" abstract="true"/>
> <element name="duration" type="duration"
> substitutionGroup="gml:_duration"/>
> <element name="tInterval" type="gml:TMIntervalLengthType"
> substitutionGroup="gml:_duration"/>
> <element name="interval" type="gml:IntervalType"
> substitutionGroup="gml:_duration"/>
>
> <simpleType name="TMDurationType">
> <union memberTypes="duration positiveInteger double"/>
> </simpleType>
>
> <complexType name="TMIntervalLengthType" final="#all">
> <simpleContent>
> <extension base="positiveInteger">
> <attribute name="unit" type="gml:TimeUnitType" use="required"/>
> <attribute name="radix" type="positiveInteger" use="optional"/>
> <attribute name="factor" type="integer" use="optional"/>
> </extension>
> </simpleContent>
> </complexType>
>
> <complexType name="IntervalType" final="#all">
> <simpleContent>
> <extension base="double">
> <attribute name="unit" type="gml:TimeUnitType" use="required"/>
> </extension>
> </simpleContent>
> </complexType>
Yes, I believe so. The gml:tInterval and gml:interval elements' types
are governed by Schema Component Constraint: Type Derivation OK
(Complex) which states:
For a complex type definition (call it D, for derived) to be validly
derived from a type definition (call this B, for base) given a
subset of {extension, restriction} all of the following must be
true:
1 If B and D are not the same type definition, then the
{derivation method} of D must not be in the subset.
2 One of the following must be true:
2.1 B and D must be the same type definition.
2.2 B must be D's {base type definition}.
2.3 All of the following must be true:
2.3.1 D's {base type definition} must not be the ·ur-type
definition·.
2.3.2 The appropriate case among the following must be true:
2.3.2.1 If D's {base type definition} is complex, then
it must be validly derived from B given the
subset as defined by this constraint.
2.3.2.2 If D's {base type definition} is simple, then it
must be validly derived from B given the subset
as defined in Type Derivation OK (Simple)
(§3.14.6).
http://www.w3.org/TR/xmlschema-1/#cos-ct-derived-ok
In the case of gml:tInterval, for example, we need to check that
gml:TMIntervalLengthType (a complex type with simple content) is a
valid derivation of gml:TMDurationType. This falls under clause
2.3.2.2, so we then need to check that gml:TMIntervalLengthType's base
type definition -- xs:duration -- is validly derived from
gml:TMDurationType. This is governed by Schema Component Constraint:
Type Derivation OK (Simple):
For a simple type definition (call it D, for derived) to be validly
derived from a simple type definition (call this B, for base) given
a subset of {extension, restriction, list, union} (of which only
restriction is actually relevant) one of the following must be true:
1 They are the same type definition.
2 All of the following must be true:
2.1 restriction is not in the subset, or in the {final} of its own
{base type definition};
2.2 One of the following must be true:
2.2.1 D's ·base type definition· is B.
2.2.2 D's ·base type definition· is not the ·simple ur-type
definition· and is validly derived from B given the
subset, as defined by this constraint.
2.2.3 D's {variety} is list or union and B is the ·simple
ur-type definition·.
2.2.4 B's {variety} is union and D is validly derived from a
type definition in B's {member type definitions} given
the subset, as defined by this constraint.
http://www.w3.org/TR/xmlschema-1/#cos-st-derived-ok
Here, clause 2.2.4 is relevant, since gml:TMDurationType is a union
type; xs:duration is validly derived from one of the member type
definitions (specifically xs:duration) because they are the same type
definition.
Of course this only works because you're not blocking any of the
derivations; adding block="extension" to either the element
declaration of gml:_duration or the type definition of
gml:TMDurationType would stop it being valid, I think.
Funky! I hadn't explored this corner of the spec before.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 1 May 2002 04:39:34 UTC