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 09:39:04 +0100
Message-ID: <144344908762.20020426093904@jenitennison.com>
To: Simon.Cox@csiro.au
CC: xmlschema-dev@w3.org
Hi Simon,

> 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?

There's no way to explicitly say "restrict this union to this
particular type", but in some cases you could achieve the same result
by restricting the union using a pattern.

> For example, starting with a "supertype"
>
>   <simpleType name="TMDurationType">
>     <union memberTypes="duration positiveInteger double"/>
>   </simpleType>
>
> can this be restricted to "duration" only?  

So in this case you could use:

<xs:simpleType name="TMPeriodDurationType">
  <xs:restriction base="TMDurationType">
    <xs:pattern value="P.*" />
  </xs:restriction>
</xs:simpleType>

(You could make the pattern more detailed, but there's no real reason
to.)

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Friday, 26 April 2002 04:39:10 GMT

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