W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2002

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

From: <Simon.Cox@csiro.au>
Date: Sun, 28 Apr 2002 10:03:55 +0800
Message-ID: <116D27C8E12BD411B3AB00B0D022B0B8010E5620@yate.wa.csiro.au>
To: xmlschema-dev@w3.org
Cc: rmartell@galdosinc.com
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?


------Original Message-----
From: Jeni Tennison
To: Simon.Cox@csiro.au
Cc: xmlschema-dev@w3.org
Sent: 26/04/2002 4:39 PM
Subject: Re: Restricting a union? was RE: Schema for schemas bugs?

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 Saturday, 27 April 2002 22:14:34 GMT

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