<xsd:attributeGroup> ElementÂ
Groups a set of attribute declarations so that they can be incorporated as a group for complex type definitions.
<attributeGroup
id = ID
name = NCName
ref = QName
{any attributes with non-schema Namespace...}>
Content: (annotation?), ((attribute | attributeGroup)*, anyAttribute?))
</attributeGroup>
Attributes
id
The ID of this element. The id value must be of type ID and be unique within the document containing this element.Optional.
name
The name of the attribute group whose attributes are included in an attributeGroup element or complexType element. The name must be a no-colon-name (NCName) as defined in the XML Namespaces specification. Name and ref attributes cannot both be present. Name attribute can only be present if the attribute group is a child of the schema element.Optional.
ref
The reference name of the attribute group whose attributes are included in an attributeGroup element or complexType element.Name and ref attributes cannot both be present. Ref attribute can only be present if the attribute group is not a child of the schema element.
This value must be a qualified name (QName).
Optional.
Element Information
Number of occurrences |
Unlimited |
Parent elements |
attributeGroup, complexType, schema, restriction (simpleContent), extension (simpleContent), restriction (complexContent), extension (complexContent) |
Contents |
annotation, attribute, attributeGroup, anyAttribute |
Remarks
An attribute group can be defined only as a child of the schema element. In this case, the name attribute must be present and contain the attribute, attributeGroup, or anyAttribute elements that make up the attribute group.
An attribute group can be included in an attributeGroup or complexType, in which case, the ref attribute must be present and the attributeGroup element must be empty. See the following example.
The attributeGroup elements can contain other attributeGroup elements.
Example
The following example shows an attribute group defined (myAttributeGroup) and used in a complex type (myElementType).
<xs:attributeGroup name="myAttributeGroup">
<xs:attribute name="someattribute1" type="xs:integer"/>
<xs:attribute name="someattribute2" type="xs:string"/>
</xs:attributeGroup>
<xs:complexType name="myElementType">
<xs:attributeGroup ref="myAttributeGroup"/>
</xs:complexType>
The following example shows two attribute groups defined (myAttributeGroupA and myAttributeGroupB) with one containing the other.
<xs:attributeGroup name="myAttributeGroupA">
<xs:attribute name="someattribute10" type="xs:integer"/>
<xs:attribute name="someattribute11" type="xs:string"/>
</xs:attributeGroup>
<xs:attributeGroup name="myAttributeGroupB">
<xs:attribute name="someattribute20" type="xs:date"/>
<xs:attributeGroup ref="myAttributeGroupA"/>
</xs:attributeGroup>
Other Resources
For more information see the W3C XML Schema Part 1: Structures Recommendation at www.w3.org/TR/2001/REC-xmlschema-1-20010502\#element-all.