XML Schema keyref element
Definition and usage
The keyref element specifies the attribute or element value (or a set of values) corresponding to the specified key or unique element value.
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 for the selected element may not be unique, but the combination of all fields must be unique.
Element information
Number of occurrences | Once |
Parent element | element |
Content | annotation、field、selector |
Grammar
<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 time, the + symbol declares that the element must appear one or more times.)
Attributes | Description |
---|---|
id | Optional. Define a unique ID for the element. |
name | Required. Define the name of the key element. |
refer | Required. Define 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. Define any other attributes with non-schema namespace. |