Re: Extending an enumeration

Hi Florent,
    Related to this use-case, here's a different way of thinking about
XSD type inheritance in XSD 1.1 world.

<xs:complexType name="working-days">
    <xs:simpleContent>
  <xs:extension base="week-days">
      <xs:assert test="not($value = ('saturday', 'sunday'))"/>
  </xs:extension>
    </xs:simpleContent>
</xs:complexType>
 
 
<xs:simpleType name="week-days">
      <xs:restriction base="xs:string">
    <xs:enumeration value="monday"/>
    <xs:enumeration value="tuesday"/>
    <xs:enumeration value="wednesday"/>
    <xs:enumeration value="thursday"/>
    <xs:enumeration value="friday"/>
    <xs:enumeration value="saturday"/>
    <xs:enumeration value="sunday"/>
      </xs:restriction>
</xs:simpleType>

These set of XSD types, doesn't exactly model XSD components as per
your modeling recommendations (i.e, a simpleType should extend another
simpleType). But this allows us, to reuse the specification of value
space of one XSD type ("week-days") within another type definition
("working-days"). In this example, the derived type is using an
<assert> to constrain the value space of the base type.

Does this look somewhat ok?

On Wed, Jul 25, 2012 at 11:02 AM, Florent Georges <lists@fgeorges.org> wrote:
>   Hi,
>
>   I struggle with a simple problem.  I have two simple types,
> both are enumerations, one is a subset of the other.  Lets' say:
>
>     working-days:
>       - monday, tuesday, wednesday, thursday, friday
>     week-days:
>       - { working-days }, saturday, sunday
>
>   I would like to have "week-days" defined as an extension of
> "working-days".  Sounds sensible, doesn't it?  But I cannot find
> how to do it...
>
>   Any idea?
>
>   Regards,
>
> --
> Florent Georges
> http://fgeorges.org/
> http://h2oconsulting.be/
>



-- 
Regards,
Mukul Gandhi

Received on Thursday, 26 July 2012 21:34:12 UTC