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 for the selected element may not be unique, 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
خصائص أي
>
(annotation?,(selector,field+))
</key>

الرمز الـ (? ) يدل على أن العنصر يمكن أن يظهر صفر مره أو مره واحدة في عنصر key، والرمز الـ (+) يدل على أن العنصر يجب أن يظهر مره واحدة أو مرات متعددة.

الخصائص الوصف
id اختياري. يحدد ID الفريد للعنصر.
الاسم مطلوب. يحدد اسم عنصر key.
خصائص أي اختياري. يحدد أي خصائص أخرى تحتوي على مساحة اسمية غير النمطية.