xs:key

Purpose

Defines an identity constraint of type key. The values of an identity constraint are extracted from an XML fragment that is validated against the parent element declaration. They must be unique, and they must be complete, i.e. each item in the tuple must be set.

For details of the construction of the tuples representing the values of an identity constraint, please see section 3.11.4 Identity-constraint Definition Validation Rules of the W3C documentation XML Schema Part 1: Structures.

Parent element xs:element
Child elements xs:annotation, xs:field, xs:selector
Attributes id, name
Attributes
Name Type Description
id xs:ID Assigns an identifier to the schema node.
name xs:NCName

The names of all identity constraints (xs:key, xs:keyref and xs:unique) must be unique within a schema document.

An xs:key identity constraint can be referenced by an xs:keyref identity constraint that cites the name of the xs:key identity constraint in the refer attribute.