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. 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 exactly 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

Occurrence times Unrestricted
Parent element element
Content annotation、field、selector

Syntax

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

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

Eigenschaften Beschreibung
id Optional. Regelt die einzigartige ID dieses Elements.
name Erforderlich. Regelt den Namen des key Elements.
beliebige Attribute Optional. Regelt jede andere Eigenschaft mit non-schema Namensraum.