XML Schema attributeGroup Element
Definition and Usage
The attributeGroup element is used to combine attribute declarations so that these declarations can be merged into complex types as a combination.
Element Information
Occurrence | Unrestricted |
Parent Element | attributeGroup, complexType, schema, restriction (simpleContent), extension (simpleContent), restriction (complexContent), extension (complexContent) |
Content | annotation, attribute, attributeGroup, anyAttribute |
Syntax
<attributeGroup id=ID name=NCName ref=QName any attributes > (annotation?),((attribute|attributeGroup)*,anyAttribute?)) </attributeGroup>
(The ? symbol declares in the attributeGroup element, the element can appear zero or one times, the * symbol declares the element can appear zero or more times.)
Attributes | Description |
---|---|
id | Optional. Specifies the unique ID of the element. |
name | Optional. Specifies the name of the attribute group. The name and ref attributes cannot appear at the same time. |
ref | Optional. Specifies references to the specified attribute groups. The name and ref attributes cannot appear at the same time. |
any attributes | Optional. Specifies any other attributes with a non-schema namespace. |
Example
<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 above example defines an attribute group named "personattr" that is used in the complex type named "person".