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

Re: pair interactions in XML schema

From: Jeni Tennison <jeni@jenitennison.com>
Date: Mon, 17 Jun 2002 10:22:50 +0100
Message-ID: <86-1809565778.20020617102250@jenitennison.com>
To: xmlschema-dev@w3.org
CC: Jos van den Oever <oever@fenk.wau.nl>, "Bob Schloss" <rschloss@us.ibm.com>

Bob Schloss wrote:
> 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.).

I don't think that it's possible to express this in XML Schema,
because of the rule that the fields of identity constraints must only
select one information item. If the identity constraint was expressed

  <xs:key name="acquaintances">
    <xs:selector xpath="acquaintance" />
    <xs:field xpath="person/@name" />

then the field would select two name attributes and therefore be
invalid. If XML Schema allowed positional predicates, you could use:

  <xs:key name="acquaintances">
    <xs:selector xpath="acquaintance" />
    <xs:field xpath="person[1]/@name" />
    <xs:field xpath="person[2]/@name" />

but it doesn't, so you can't.

I think that the only way around is to make each acquaintance hold
differently named child elements (e.g. person1 and person2) and then

  <xs:key name="acquaintances">
    <xs:selector xpath="acquaintance" />
    <xs:field xpath="person1/@name" />
    <xs:field xpath="person2/@name" />

although that isn't perfect, for the reasons Bob points out:

> 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).



Jeni Tennison
Received on Monday, 17 June 2002 05:22:52 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:57 UTC