XML Schema attributeGroup 元素
❮ 完整的 XML Schema 参考
定义和用法
attributeGroup 元素用于对一组属性声明进行分组,以便可以将它们作为一个组并入复杂类型定义中。
元素信息
- 父元素: attributeGroup, complexType, schema, restriction (simpleContent 和 complexContent), extension (simpleContent 和 complexContent)
语法
<attributeGroup
id=ID
name=NCName
ref=QName
任何属性
>
(annotation?),((attribute|attributeGroup)*,anyAttribute?))
</attributeGroup>(? 符号表示该元素可以出现零次或一次,* 符号表示该元素可以在 attributeGroup 元素内出现零次或多次)
| Attribute | 描述 |
|---|---|
| id | 可选。指定元素的唯一 ID |
| name | 可选。指定属性组的名称。name 和 ref 属性不能同时存在 |
| ref | 可选。指定对命名属性组的引用。name 和 ref 属性不能同时存在 |
| 任何属性 | 可选。指定任何其他非 schema 命名空间的属性 |
示例 1
<xs:attributeGroup name="personattr">
<xs:attribute name="attr1" type="string"/>
<xs:attribute name="attr2" type="integer"/>
</xs:attributeGroup>
<xs:complexType name="person">
<xs:attributeGroup ref="personattr"/>
</xs:complexType>上面的示例定义了一个名为 "personattr" 的属性组,该属性组在名为 "person" 的复杂类型中使用。
❮ 完整的 XML Schema 参考