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?
> 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:complexType name="TMDurationTypeBase">
    <xs:extension base="gml:TMDurationType" />

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

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?



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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:56 UTC