XML Schema key element

Definition and Usage

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

The key element must sequentially contain the following elements:

selector element:

There must be exactly one selector element.

The selector element contains an XPath expression that specifies an element set, in which the value specified by the 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 present 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-Informationen

Anzahl der Auftretungen Unbeschränkt
Übergeordnetes Element element
Inhalt annotation, field, selector

Grammatik

<key
id=ID
name=NCName
jegliche Attribute
>
(annotation?,(selector,field+))
</key>

(? Symbol wird im key-Element deklariert, Element kann null oder einmal auftreten, + Symbol deklariert, dass das Element einmal oder mehrmals auftreten muss.)

Attribute Beschreibung
id Optional. Regelt den eindeutigen ID der Element.
name Erforderlich. Regelt den Namen des key-Elements.
jegliche Attribute Optional. Regelt jede andere Eigenschaft mit non-schema-Namespace.