# Adding an attribute group

An attribute group definition is an association between a name and a set of attribute declarations, enabling re-use of the same set in several complex type definitions. Named groups of attribute declarations can greatly facilitate the maintenance and reuse of common attribute declarations in an XML schema.

The following instructions were written for the Resource perspective, but they will also work in many other perspectives.

To add an attribute group to an XML schema, follow these steps:

1. Open your XML schema in the XML schema editor.
2. In the Outline view, right-click the XML schema and click Add Attribute Group. It appears in the Attribute Groups folder.
3. Select your new group, and in the Properties view, type a name for the attribute group in the Name field.
4. To add an attribute, right-click your attribute group in the Outline view, click Add Attribute. The attribute appears below the attribute group in the Outline view.
   1. Select the attribute, and in the Properties view, type the Name of it.
   2. Click the More button and specify the type for the attribute. To specify that an attribute's type is anonymous, when the User-defined simple type radio button is selected, click **anonymous** in the type list. The anonymous type is added to the outline under the attribute. Expand the attribute to see it. You can then start adding content to the new anonymous type.
5. An attribute reference provides a reference to a global attribute. To add an attribute reference, right-click your attribute group, and click Add Attribute Ref. A declaration that references a global attribute enables the referenced attribute to appear in the instance document in the context of the referencing declaration. The menu option to add an attribute reference only appears if there are global attributes defined elsewhere in the document.
   1. Select the reference (which appears below the attribute group in the Outline view), then select the global attribute you want it to reference from the ref drop down list.
6. An attribute group reference provides a reference to an attribute group. To add an attribute group reference, right-click your attribute group, and click Add Attribute Group Ref, and fill in the field values as necessary. A declaration that references an attribute group enables the referenced attribute group to appear in the instance document in the context of the referencing declaration. The menu option to add an attribute group reference only appears if there are attribute groups defined elsewhere in the document.
   1. Select the reference (which appears below the attribute group in the Outline view), then select the attribute group you want it to reference from the ref drop down list.
7. An `any` element enables attributes to appear in `any` elements. To add an `any` attribute, right-click in your attribute group and click Add Any Attribute. The `any` appears below the attribute group in the Outline view. You can specify the following values for an `any` attribute:
   - For a namespace value, you can select ##any (this allows any well-formed XML from any namespace), ##local (this allows any well-formed XML that is not declared to be in a namespace, ##other (this allows any well-formed XML that is not from the target namespace of the type being defined) or ##targetNamespace (which is shorthand for the target namespace of the type being defined).
   - For a processContents value, you can select skip (the XML processor will not validate the attribute content at all), lax (the XML processor will validate the attribute content as much as it can), or strict (the XML processor will validate all the attribute content).

(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.