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 containing element in the instance document. 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 a unique value (attribute or element value) 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
occurrence times | unrestricted |
parent element | element |
content | annotation、field、selector |
grammatical
<key id=ID name=NCName any attributes > (annotation?,(selector,field+)) </key>
(? 符號聲明在 key 元素中,元素可出現零次或一次,+ 符號聲明元素必須出現一次或多次。)
屬性 | 描述 |
---|---|
id | 可選。規定該元素的唯一的 ID。 |
name | 必需。規定 key 元素的名稱。 |
any attributes | 可選。規定帶有 non-schema 命名空间的任何其他屬性。 |