W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2012

Re: Extending an enumeration

From: C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>
Date: Thu, 26 Jul 2012 12:26:27 -0600
Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-Id: <C1E8392A-9F01-4BCE-860C-B3E3BF79A023@blackmesatech.com>
To: Florent Georges <lists@fgeorges.org>

On Jul 25, 2012, at 4:02 AM, Florent Georges 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?

Ideally, a schema language should distinguish carefully between
two relationships that can hold between two types:

  - The subset/superset relation holds when every
    value of T1 is a value of T2.

  - The subsumption relation holds when every value of
    T1 is subsumed by T2 -- where the precise nature of
    the 'subsumes' relation must be carefully defined, but
    informally means that one type provides "all the information"
    provided by the other type, and a bit more.

In XSD, the 'restriction' operation defines a subset relation
between two types, but there is no operation to define a 
superset relation.  The 'extension' operation defines a
subsumption relation (the base type subsumes the 
extended type) but there is no way to define the inverse
relation.  Lack of orthogonality often results from a failure
of design work to identify clear and useful primitive notions.

As Michael Kay observes, you can define week-days as a
union of working-days and {saturday, sunday}, but the 
relation between the union type and the working-days type
is not one that XSD-aware processors or languages can
do much with. (In particular, unions which have T1 as a 
member are not accepted as extensions of T1.)

So on the level of theoretical purity and conceptual beauty,
you're hosed.

On the practical level, whether you're hosed or not depends
on what exactly you want to do.  Why do you want
week-days as an extension of working-days, and not
working-days as a restriction of week-days?  What operations
are you trying to support or optimize?


-- 
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com 
* http://cmsmcq.com/mib                 
* http://balisage.net
****************************************************************
Received on Thursday, 26 July 2012 18:26:53 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 July 2012 18:26:53 GMT