W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2002

Re: Restricting a union? was RE: Schema for schemas bugs?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Sun, 28 Apr 2002 18:42:23 +0100
Message-ID: <72550302823.20020428184223@jenitennison.com>
To: Simon.Cox@csiro.au
CC: xmlschema-dev@w3.org, rmartell@galdosinc.com
Hi Simon,

> Jeni wrote:
>> There's no way to explicitly say "restrict this union to this
>> particular type"
>
> However, in "Structures" at 
>
>   http://www.w3.org/TR/xmlschema-1/#coss-st 
>
> in the section 
>
>   "Schema Component Constraint: Type Derivation OK (Simple)" 
>
> clause 2.2.4 says that it is OK if:
>
>   "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." 
>
> Of course, this begs the question of "how", but implies that this
> requirement has been considered. Is there a contradiction here?

Well found! This schema component constraint is referenced in a number
of places:

  - when defining the types that you can assign to an element in the
  instance using xsi:type in Validation Rule: Element Locally Valid
  (Element) and Validation Rule: Schema-Validity Assessment (Element)

  - when defining the types that an element can have given it's a
  member of a substitution group, in Schema Component Constraint:
  Element Declaration Properties Correct

  - when defining the types that an attribute can have given it's part
  of a restriction, in Schema Component Constraint: Derivation Valid
  (Restriction, Complex)

  - when defining the types that can be derived from as the base of a
  complex type, in Schema Component Constraint: Type Derivation OK
  (Complex)

  - when defining the types that an element particle can have given
  it's used in a derivation by restriction and matches a given element
  particle in the base, in Schema Component Constraint: Particle
  Restriction OK (Elt:Elt NameAndTypeOK)

Of those, I think that the one that's most helpful with the problem in
hand is the second. The rules in Schema Component Constraint: Element
Declaration Properties Correct
(http://www.w3.org/TR/xmlschema-1/#e-props-correct) imply that you
could do:

<xs:simpleType name="TMDurationType">
  <xs:union memberTypes="duration positiveInteger double"/>
</xs:simpleType>

<xs:element name="Duration" type="gml:TMDurationType"
            abstract="true" />

<xs:element name="TimeDuration" type="xs:duration"
            substitutionGroup="gml:Duration" />
<xs:element name="SecsDuration" type="xs:positiveInteger"
            substitutionGroup="gml:Duration" />
<xs:element name="MinsDuration" type="xs:double"
            substitutionGroup="gml:Duration" />

In other words, while you can't derive a named atomic simple type from
the union type explicitly, you can refer to the member types of that
union type by name when declaring the elements that are part of a
substitution group, and the substitution group will work. I hadn't
spotted that before -- I think it addresses your problem exactly,
though, doesn't it?
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Sunday, 28 April 2002 14:40:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:30 GMT