Re: pair interactions in XML schema

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 UTC