- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Tue, 2 Apr 2002 16:50:48 +0100
- To: Gary Cramblitt <garycramblitt@comcast.net>
- CC: xmlschema-dev@w3.org
Hi Gary, >> 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. > > This is a database application. The LineID and RadioService fields > are the primary key of the Rec_SelRadioSrvc table; a multi-field > key. So, if I understand what you are saying I should move the > UNIQUE constraint into the element containing Rec_SelRadioSrvc or > into the root element (since there aren't any other tables with the > name "Rec_SelRadioSrvc"). And leave the selector as is. Correct? Yes, you can define the identity constraint to the declaration of any ancestor of the Rec_SelRadioSrvc elements. But you must make sure that the XPath that you use in the selector is the correct one for wherever you place the identity constraint. The XPath that you use in the selector needs to show the validator the way from the element in which you define the identity constraint to the elements that you're saying have a unique set of fields. If the element in which you define the identity constraint is the parent of the elements that you're saying are unique, then you need to just give the name of the elements. So if you define the identity constraint in the parent of the Rec_SelRadioSrvc elements, then you must use: <xs:selector xpath="Rec_SelRadioSrvc" /> If the structure was something like: <data> <Rec_SelRadioSrvcs> <Rec_SelRadioSrvc>...</Rec_SelRadioSrvc> <Rec_SelRadioSrvc>...</Rec_SelRadioSrvc> ... </Rec_SelRadioSrvcs> </data> and you put the identity constraint in the declaration for the data element, then you must use: <xs:selector xpath="Rec_SelRadioSrvc/Rec_SelRadioSrvc" /> and so on. The XPath takes you from the element in which the identity constraint is defined down to the elements that are unique. Does that make sense? Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Tuesday, 2 April 2002 10:50:49 UTC