XML Schema keyref 元素

定义和用法

keyref 元素规定属性或元素值(或一组值)对应指定的 key 或 unique 元素的值。

keyref 元素必须按顺序包含下列元素:

selector 元素:

必须有一个且只有一个 selector 元素。

selector 元素包含一个 XPath 表达式,该表达式指定一个元素集,在元素集中,field 指定的值必须是唯一的。

field 元素

必须有一个或多个 field 元素。

每一个 field 元素均包含一个 XPath 表达式,该表达式指定对于由 selector 元素指定的元素集而言必须唯一的值(属性或元素值)。

如果有多个 field 元素,则 field 元素的组合必须是唯一的。在此情况下,单个 field 元素的值对于选定元素不一定是唯一的,但所有字段的组合必须是唯一的。

元素信息

出现次数 一次
父元素 element
内容 annotation、field、selector

语法

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

(? Symbol declaration in key element, element can appear zero or one time, + Symbol declaration 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 namespace.