Re: pair interactions in XML schema

                                                                                                               
                                                                                                               
                                                                                                               


Jos,

You can get close to this with 2 different <unique> identity-definition
constraints.

The first one, which will be part of the definition of element
acquaintance, will specify that all the fields person/@name within 1
acquaintance must have unique values.

The second one, which will be part of the definition of the element which
contains all the acquaintance elements (and possibly all the person
elements also),  will say that the concatenation of all fields person/@name
within selector acquaintance must be unique.  (I'm not 100% certain that
naming a single field when that element/particle (person) is declared
minOccurs="2" maxOccurs="2" actually does this.).

However, this second <unique) will not enforce your condition *unless* your
documents always specify the two child elements of acquaintance in some
fixed order, such as the person whose name is lowest in alphabetical order
always comes first, or the person which appears in the person elements
order comes first.  (And there's no way to tell a validator to check that).

There are supplements to the W3C XML Schema language, such as Schematron,
that give richer language for specifying cross-element content relationship
constraints.  They have not been endorsed by the W3C.  The possibility of
enriching the W3C XML Schema language in a future version comes up for
discussion from time to time.

Bob Schloss
IBM Watson Research Center
Hawthorne, NY, USA



Jos van den Oever <oever@fenk.wau.nl>@w3.org on 06/15/2002 01:28:30 PM

Sent by:    xmlschema-dev-request@w3.org


To:    xmlschema-dev@w3.org
cc:
Subject:    pair interactions in XML schema







Hi all,

For the description of pair interactions I'd like to be able to make an XML
file like this (items renamed for convenience):

<person name='Jack'>...</person>
<person name='Jane'>...</person>
<person name='Pete'>...</person>

<acquaintance years='9'><person name='Jack'><person
name='Pete'></<acquaintance>
<acquaintance years='1'><person name='Pete'><person
name='Jane'></<acquaintance>
<acquaintance years='3'><person name='Jack'><person
name='Jane'></<acquaintance>

Of course, each acquaintance between two persons can only be defined once.
And
the acquaintance of one person with the same person cannot be defined
either.

Is it possible to enforce these rules with Schema?
It seems I cannot use complexTypes as keys, which would solve the problem.

Best regards, Jos

Received on Sunday, 16 June 2002 08:03:52 UTC