当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XML Schema attributeGroup 元素
The attributeGroup element is used to group a set of attribute declarations so that they can be incorporated as a group into complex type definitions.
attributeGroup元素的作用是:将一组属性声明群组到复合类型声明中。
<attributeGroup id=ID name=NCName ref=QName any attributes > (annotation?),((attribute|attributeGroup)*,anyAttribute?)) </attributeGroup> |
(The ? sign declares that the element can occur zero or one time, and the * sign declares that the element can occur zero or more times inside the attributeGroup element)
“?”符号用于声明元素可以出现的次数(0次或1次),“*”符号用于声明元素可以在attributeGroup元素中出现的次数(0次或多次)。
属性 | 描述 |
---|---|
id | Optional. Specifies a unique ID for the element 可选参数。为元素指定一个独立的ID |
name | Optional. Specifies the name of the attribute group. Name and ref attributes cannot both be present 可选参数。指定属性组名称。名称和ref 属性不能同时存在 |
ref | Optional. Specifies a reference to a named attribute group. Name and ref attributes cannot both be present 可选参数。为一个已命名的属性指定一个参数。名称和ref 属性不能同时存在。 |
any attributes | Optional. Specifies any other attributes with non-schema namespace 可选参数。指定其它的非schema命名空间的属性 |
<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> |
The example above defines an attribute group named "personattr" which is used in a complex type named "person".
上述案例定义了一个名为“personattr”的属性组,该属性组是在名为“person”的复合类型中使用的。