RE: More Key/Keyref Questions

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