XML Schema keyref element

Definition and Usage

The keyref element specifies that the attribute or element value (or a set of values) corresponds to the value of the specified key or unique element.

The keyref element must sequentially contain the following elements:

selector element:

There must be one and only one selector element.

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 once
parent element element
Content annotation, field, selector

Syntax

<keyref
id=ID
name=NCName
refer=QName
any attributes
>
(annotation?,(selector,field+))
</include>

(The ? symbol declares in the key element, the element can appear zero or one times, the + symbol declares the element must appear one or more times.)

Attributes Description
id Optional. Specifies a unique ID for the element.
name Required. Specifies the name of the key element.
refer Required. Specifies the name of the key or unique element defined in the schema (or any other schema indicated by the specified namespace). The refer value must be a qualified name (QName). The type can include namespace prefixes.
any attributes Optional. Specifies any other attributes with non-schema namespaces.