Name

xs:key

Attributes

name

A name for the key (not namespace qualified, as it uses the namespace of the schema)

Contents

xs:annotation?, (xs:selector, xs:field+)

xs:key lets you state that parts of a document must have specific values unique across the set of parts for the document to be valid. An xs:key element uses the XPath value in an xs:selector element to identify where the key applies, and the xs:field element to specifically identify which part of the document must be both present and unique among those values.

xs:key elements may appear only as children of xs:element. The xs:selector XPaths are calculated from the element in which the key is defined, while the xs:field XPaths are calculated from the selector. The name attribute is used for identification with xs:keyref. Also, xs:key behaves exactly like xs:unique, except that xs:unique does not require the values it identifies to be present.

Get XML Pocket Reference, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.