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 11:39:23 +0100
Message-ID: <26-1804972513.20020617113923@jenitennison.com>
To: Jos van den Oever <oever@fenk.wau.nl>
CC: xmlschema-dev@w3.org, "Bob Schloss" <rschloss@us.ibm.com>

Hi Jos,

> So you can't share keys between objects, for example require that
> all <coutryside> and <city> objects have unique geographical
> locations?

No, you *can* share keys between elements. You can select as many
elements as you like and say that they have distinct identifiers --
these are the elements that you select with the xpath attribute in the
xs:selector element, as in:

  <xs:key name="geography">
    <xs:selector xpath="countryside | city" />
    ...
  </xs:key>

Each identifier can be made up of several fields. So for example you
could have separate fields for longitude and latitude and use those to
identify countryside and city elements:

  <xs:key name="geography">
    <xs:selector xpath="countryside | city" />
    <xs:field xpath="longitude" />
    <xs:field xpath="latitude" />
  </xs:key>

But each individual field can only select one element or attribute for
any particular selected element. In the above, each countryside
element can only have one longitude element and one latitude element.
If it had any more, it would be an error.

So in your case, to select person1, person2 and person3 and say that
they all have unique names, you should have something like:

  <xs:key name="people">
    <xs:selector xpath="person1 | person1/person2 |
                        person1/person2/person3" />
    <xs:field xpath="@name" />
  </xs:key>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Monday, 17 June 2002 06:39:26 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:31 GMT