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: Fri, 26 Apr 2002 10:27:18 +0100
Message-ID: <140347803034.20020426102718@jenitennison.com>
To: xmlschema-dev@w3.org
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 GMT

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