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 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 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 |
Syntax
<key id=ID name=NCName any attributes > (annotation?,(selector,field+)) </key>
(The '?' symbol declares the element in the key element, which can appear zero or one time, and the '+' symbol declares that the element must appear one or more times.)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element. |
name | Required. Specifies the name of the key element. |
any attributes | Optional. Specifies any other attributes with non-schema namespace. |