How to use the unique tag in an xsd file within a complex type?
uniqueidentifier, xml, xsd
Solution
In XSD, identity constraints are associated with elements, not with types. So define the identity constraint on the element(s) in your schema defined as having type `flighttype`, not on `flighttype` itself.
Problem
I have seen examples on how to use the unique tag directly in an element declaration in an xsd, but I cannot figure out how to put into an element declaration that is a complextype, see the code below: ``` <xs:complexType name="flighttype"> <xs:sequence> <xs:element name="departure" type="departuretype"/> <xs:element name="arrival" type="arrivaltype"/> <xs:element name="altitude" type="xs:string"/> <xs:element name="speed" type="xs:string"/> <xs:element name="distance" type="xs:string"/> <xs:element name="entertainment" type="entertainmenttype"/> <xs:element name="safetymessage" type="xs:string"/> </xs:sequence> <xs:attribute name="id" type="xs:string"/> <xs:attribute name="airline" type="xs:string"/> <xs:attribute name="flightno" type="xs:string"/> <xs:attribute name="model" type="xs:string"/> <xs:attribute name="passengers" type="xs:integer"/> <xs:attribute name="status" type="xs:string"/> </xs:complexType> ``` I want to make the id a unique id, I can get the following example to work, but its used directly within an element declaration. Example Thank you!