XML Schema key element

Definition and usage

The attribute or element value (or a set of values) specified by the key element must be a key within the specified range. The range of keys is the element contained in the instance document. A key means that the data within the specified range should be unique, non-zero, and always existent.

The key element must sequentially contain the following elements:

selector element:

There must be one and only one selector element.

The selector element contains an XPath expression that specifies an element set in which the value specified by field must be unique.

field element

There must be one or more field elements.

Each field element contains an XPath expression that specifies the unique value (attribute or element value) that must be specified for the element set specified by the selector element.

If there are multiple field elements, the combination of field elements must be unique. In this case, the value of a single field element may not be unique for the selected element, but the combination of all fields must be unique.

element information

number of occurrences unrestricted
parent element element
content annotation、field、selector

grammar

<key
id=ID
name=NCName
ویژگی‌های any
>
(annotation?,(selector,field+))
</key>

(? نشانه‌ای برای اعلام در عنصر key، وجود این عنصر صفر یا یک بار است، + نشانه‌ای برای اعلام که عنصر باید یک یا چند بار وجود داشته باشد.)

ویژگی‌ها توضیحات
id اختیاری. ID منحصر به فرد این عنصر را مشخص می‌کند.
name ضروری. نام عنصر key را مشخص می‌کند.
ویژگی‌های any اختیاری. هر ویژگی دیگری با نام فضای نام غیر اسکیمای تعریف شده را مشخص می‌کند.