특성 또는 요소 값(또는 특성 또는 요소 값의 조합)이 지정한 범위 내에서 고유하도록 지정합니다. 값은 고유하거나 0이어야 합니다.
<unique
id = ID
name = NCName
{any attributes with non-schema Namespace}...>
Content: (annotation?, (selector, field+))
</unique>
특성
id
이 요소의 ID입니다. id 값은 ID 형식이어야 하며 이 요소를 포함하는 문서 내에서 고유한 값이어야 합니다.선택적 항목입니다.
name
unique 요소의 이름입니다. 이 이름은 XML 네임스페이스 사양에 정의된 대로 NCName(No-Colon-Name)이어야 합니다.이름은 identity 제약 조건 집합 내에서 고유해야 합니다.
필수 항목입니다.
요소 정보
발생 횟수 |
한 번 |
부모 요소 |
|
내용 |
주의
unique 요소에는 다음 요소가 순서대로 포함되어야 합니다.
selector |
selector 요소에는 요소 집합을 지정하는 XPath(XML Path Language) 식이 포함되며 field 요소에 지정된 값은 이 요소 집합에서 고유해야 합니다. selector 요소는 하나만 있어야 합니다. |
field |
각 field 요소에는 selector 요소에 지정된 요소 집합에 대해 고유한 값(특성 또는 요소 값)을 지정하는 XPath 식이 포함됩니다. field 요소가 여러 개인 경우에는 field 요소의 조합이 고유해야 합니다. 이 경우 선택한 요소에서 특정 field 요소의 값은 고유하지 않을 수도 있으나 모든 필드의 조합은 고유해야 합니다. field 요소는 하나 이상이어야 합니다. |
예제
다음 예제에서는 customerOrders 요소의 바인딩되지 않은 순서를 포함할 수 있는 ordersByCustomer의 루트 요소가 있는 스키마를 정의합니다. ordersByCustomer 요소에서 unique 요소는 customerID 특성이 모든 customerOrders에서 고유하도록 지정합니다.
<xs:schema targetNamespace="http://tempuri.org/myschema/unique" elementFormDefault="qualified"
xmlns="http://tempuri.org/myschema/unique"
xmlns:mstns="http://tempuri.org/myschema/unique"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="customerOrderType">
<xs:sequence>
<xs:element name="item" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="itemID" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="CustomerID" type="xs:string"/>
</xs:complexType>
<xs:element name="ordersByCustomer">
<xs:complexType>
<xs:sequence>
<xs:element name="customerOrders" type="customerOrderType"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="oneCustomerOrdersforEachCustomerID">
<xs:selector xpath="mstns:customerOrders"/>
<xs:field xpath="@customerID"/>
</xs:unique>
</xs:element>
</xs:schema>
관련 자료
자세한 내용은 www.w3.org/TR/2001/REC-xmlschema-1-20010502/\#element-all에 있는 Structures Recommendation을 참조하십시오.