将一组特性声明归为一组,以便将它们合在一起进行复杂类型定义。
<attributeGroup
id = ID
name = NCName
ref = QName
{any attributes with non-schema Namespace...}>
Content: (annotation?), ((attribute | attributeGroup)*, anyAttribute?))
</attributeGroup>
特性
id
该元素的 ID。 id 值必须属于类型 ID 并且在包含该元素的文档中是唯一的。可选。
name
其属性包括在 attributeGroup 元素或 complexType 元素中的属性组的名称。 该名称必须是在 XML 命名空间规范中定义的无冒号名称 (NCName)。 Name 和 ref 属性不能同时出现。 只在该属性组是 schema 元素的子级时才可以出现 Name 属性。可选。
ref
其属性包括在 attributeGroup 元素或 complexType 元素中的属性组的引用名称。Name 和 ref 属性不能同时出现。 只在该属性组不是 schema 元素的子级时才可以出现 Ref 属性。
该值必须是限定名 (QName)。
可选。
元素信息
出现次数 |
无限制 |
父元素 |
attributeGroup、complexType、schema、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent) |
内容 |
annotation、attribute、attributeGroup、anyAttribute |
备注
属性组只可以被定义为 schema 元素的子级。 在这种情况下,name 属性必须出现并且包含构成该属性组的 attribute、attributeGroup 或 anyAttribute 元素。
属性组可以包括在 attributeGroup 或 complexType 中;在这种情况下,ref 属性必须出现并且 attributeGroup 元素必须为空。 请参见以下示例。
attributeGroup 元素可以包含其他 attributeGroup 元素。
示例
以下示例说明在复杂类型 (myElementType) 中定义和使用的属性组 (myAttributeGroup)。
以下示例说明两个属性组(myAttributeGroupA 和 myAttributeGroupB),并且将这两个属性组定义为其中一个属性组包含另一个属性组。
其他资源
有关更多信息,请参见“W3C XML Schema Part 1: Structures Recommendation”(W3C XML 架构第 1 部分:结构建议),网址为:www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-all。