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

Dunno why my previous attempt got truncated.  
Anyway:

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>


> -----Original Message-----
> From: Jeni Tennison [mailto:jeni@jenitennison.com]
> Sent: Monday, 29 April 2002 1:42 AM
> To: Cox, Simon (E&M, Kensington)
> Cc: xmlschema-dev@w3.org; rmartell@galdosinc.com
> Subject: Re: Restricting a union? was RE: Schema for schemas bugs?
> 
> 
> 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 Wednesday, 1 May 2002 00:43:04 UTC