W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2004

RE: More Key/Keyref Questions

From: Michael Kay <mhk@mhk.me.uk>
Date: Fri, 30 Jul 2004 10:40:52 +0100
To: "'Jim Stanley'" <JimS@Media-Services.Com>, <xmlschema-dev@w3.org>
Message-Id: <20040730094135.E672EA0FEE@frink.w3.org>

> Every time I think I've got the XML schema keys and keyrefs, they
> baffle me again. 

I recognize the symptoms. My rule of thumb is:

if you have a rule that every E within the same Y must have a unique K,
(e.g. every "city" within the same "country" must have a unique "code") then
define the xs:key within the definition of Y, with a selector that selects E
from Y, and a field that selects K from E.

if you have a rule that every R within Y must have values of (I,J,K) that
match the values of (A,B,C) on some S within the same Y, (e.g. every
"manager" within a "division" must have the same ("first name", "last name")
as some "employee" within the same "division") then define a keyref within
the definition of Y with a selector that selects R from Y, and fields that
select I, J, and K from R.

The one that requires a clearer head than I have this morning is where the
scope of the keys is different from the scope of the keyrefs...

Michael Kay
Received on Friday, 30 July 2004 05:41:36 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:22 UTC