HOPEX UML : HOPEX XML Schemas : More XSD Features : XSD: Constraints : Uniqueness in XSD
   
Uniqueness in XSD
Uniqueness enables characterization of an element in a unique way. Uniqueness is modeled by a constraint on the role of a class. Its stereotype is "XSD Uniqueness".
To define uniqueness of an element:
From the schema editor:
*Select the element in the navigator.
*In its properties dialog box, select the XSD Keys tab.
To create a constraint:
*Select "Constraint".
*Click the New button.
*In the dialog box that opens, enter the name of the constraint and click OK.
 
To connect an existing constraint:
*Select "Constraint".
*To do click the Connect button.
*In the dialog box that appears, find and select the name of the constraint and click Connect.
The constraint appears in the properties dialog box.
To assign the "uniqueness" type to the constraint:
*Right-click the constraint.
*Click Properties.
*In the Characteristics tab, select the "XSD Uniqueness" stereotype.
Then specify to what the uniqueness refers:
*In the properties dialog box of the constraint, select the Texts tab.
*Select "XSD Constraint".
*Specify the elements or attributes that define the uniqueness of the element (field) as well as the path of these elements or attributes (selector). See the "Field" and "selector" tags defined by W3C schemas. XSD schemas use the xpath to characterise an attribute.
In our example, the "Title" class is uniquely defined by the "ISBN" attribute.