W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2011

Re: How to define a value space that is a cross-product of simpleType value spaces?

From: C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>
Date: Sat, 5 Mar 2011 09:34:30 -0700
Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-Id: <00CCDFA3-46A6-4055-A27D-3818407A6419@blackmesatech.com>
To: "Costello, Roger L." <costello@mitre.org>

On Feb 24, 2011, at 3:49 AM, Costello, Roger L. wrote:

> Hi Folks,
> Suppose this is the value space for "family name" values:
> ...
> Suppose this is the value space for "middle initial" values:
> ...
> Suppose this is the value space for "given name" values:
> ...
> Now there are 3 user-defined value spaces. Let me denote them by F, M, G, respectively. (F = Family, M = Middle, G = Given)
> I would like to aggregate them to create a "person name" value space. This is the value space for person name:
> Person-name is the cross product: G x M x F
> Here is an example of a value in the Person-name value space:
> ("Roger", "L", "Costello")
> How do I implement the Person-name value space?

It appears that what you want is a triple of three unnamed
values whose first value is from G, whose second value
is from M, and whose third value is from F.  (If that's not
quite what you're after, what follows will be off the mark.
While I'm in disclaimer mode I'll also say that I'm assuming this
is a simple arbitrary example built to illustrate a general question, 
and not a serious attempt to define rules for names of 

I don't know a simple way to do that in any existing schema

In XSD, the basic design principle is that for structured values
it is better to use XML.  So the simplest approximation to 
your goal in XSD is to define three attributes or elements,
associated respectively with your types F, M, and G.  The
XML serialization of a name might then be

  <name g="Roger" m="L" f="Costello"/>

This deviates from what I think you're looking for by assigning
names to the parts of the triple.  But as a general thing, I 
think that this is almost always the right way to define
Cartesian products of simple value spaces.

In DTLL, it's possible (or was, last time someone explained the
then-current state of DTLL to me) to define value spaces of
triples, but the parts of the triple were given names in order that
the type designer could specify their properties.

A different approximation would include the strings which consist
of concatenations of strings from types G, M, and F in that order.
Since the value spaces of G, M, and F are each regular sets,
and concatenation preserves regularity, it is possible to define
a single type which matches just the concatenations you want,
and to express that type as an XSD simple type definition.  (You'd
need to move the length constraints into the regular expression
patterns, and then concatenate the patterns.)

A third approximation would be to define a value space
consisting of lists of length 3, where the first item in the list
is in value space G, the second in value space M, and the
third in value space F.  This would probably be a bit tedious,
but no part of the process is particularly difficult:  (1) define
a union type U of F, G, and M.  (2) Define a list type L0 whose 
item type is U.  (3) Define a type L1 which restricts L0 to
lists of length 3.  (4) Using patterns or assertions, define
type L2 as a restriction of type L which constrains
the first token in a value to match the pattern for, or be
castable to, type G, the second token to be castable as M,
the third to be castable as F.

* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com 
* http://cmsmcq.com/mib                 
* http://balisage.net
Received on Saturday, 5 March 2011 16:35:01 UTC

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