Adding attribute groups

An attribute group definition is an association between a name and a set of attribute declarations. 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 This graphic is the More button button and specify the type for the attribute. The  Set Type dialog lists all built-in and user-defined types currently available. You can change the Scope of the list by selecting one of the following options:
      • Workspace. Lists all of the types available in your workspace.
      • Enclosing Project. Lists all of the types available in the project that contains your file.
      • (Default) Current Resource. List all of the types available in your current file.
  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 element content according to namespaces, and the corresponding any attribute element enables attributes to appear in elements. To add an any attribute, right-click your attribute group and click Add Any Attribute. The any attribute 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).