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

Simon Cox asked:
> Is it possible to derive a simpleType by restriction from a union
> simple type, such that the derived type selects just one of the
> primitivetypes from the union?
[snip]
> Why would I want to do this, you may ask? I want to put various
> versions of "duration" into a single substitution group.

I thought of another possibility here -- creating a complex type with
simple content being the union type, and then deriving another complex
type from that whose simple content is of type 'duration':

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

<xs:complexType name="TMDurationTypeBase">
  <xs:simpleContent>
    <xs:extension base="gml:TMDurationType" />
  </xs:simpleContent>
</xs:complexType>

<xs:complexType name="TMPeriodDurationType">
  <xs:simpleContent>
    <xs:restriction base="gml:TMDurationTypeBase">
      <xs:simpleType>
        <xs:restriction base="xs:duration" />
      </xs:simpleType>
    </xs:restriction>
  </xs:simpleContent>
</xs:complexType>

This doesn't feel as if it should work, on the principal that whenever
you derive by restriction the resulting content should be valid
against the base type. However, I can't see a constraint in the XML
Schema Rec that says that the content type of a complex type with
simple content has to be derived from the content type of its base
type, and both XSV and Xerces say it's valid (MSXML doesn't, though).

Have I missed something in the Rec?

Cheers,

Jeni

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

Received on Friday, 26 April 2002 05:27:19 UTC