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

Re: Problem with UNIQUE constraint

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 28 Mar 2002 08:58:18 +0000
Message-ID: <186471103320.20020328085818@jenitennison.com>
To: Gary Cramblitt <garycramblitt@comcast.net>
CC: xmlschema-dev@w3.org
Hi Gary,

>> By the way, I think that you're probably using the identity constraint
>> incorrectly. If you want to test that each Rec_SelRadioSrvc element
>> has a unique combination of LineID and RadioService, then you need to
>> place the identity constraint on the declaration of the element that's
>> the *parent* of the Rec_SelRadioServc element, as follows:
>>   <xs:unique name="ID_SelRadioSrvc">
>>     <xs:selector xpath="Rec_SelRadioSrvc"/>
>>     <xs:field xpath="LineID"/>
>>     <xs:field xpath="RadioService"/>
>>   </xs:unique>
>> As you currently have it, all you're testing is that the LineID and
>> RadioService of one Rec_SelRadioSrvc at a time. There isn't much point
>> doing that unless you're using the identity constraint sneakily to
>> test a co-occurrence constraint, which I don't think is the case here.
> Yes, you are quite right.  I need to change the selector xpath to "*".

Well, you can do, but that won't make any difference unless you also
move the xs:unique identity constraint into the element declaration
for the element that contains the elements that you want to test for
uniqueness. If you keep the xs:unique where it is, and just change the
selector xpath, then you'll be testing whether each child element of
the Rec_SelRadioSrvc (i.e. the LineID and RadioService elements) have
a unique combination of LineID and RadioService child elements, which
I doubt is what you're after.

The location where you place the xs:unique determines the scope of the
identity constraint. The xs:selector selects the elements that should
be unique. The xs:field elements identify the fields on which those
elements should be unique.



Jeni Tennison
Received on Thursday, 28 March 2002 03:58:24 UTC

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