12.2. Declaring new attributes

New attributes are declared for an element type. For example: If your well-formed XML document contains elements with a name of emphasis and you decide that you need an attribute for emphasis elements, you declare a new attribute for the element type emphasis. This attribute will be made available for all elements in your document with a name of emphasis.

Declaring attributes on the basis of element types instead of individual elements helps you to maintain a consistent set of attribute names for all elements of the same type.

To add an attribute for an element type in a well-formed XML document, follow these steps:

Declaring a new attribute

  1. Choose Element->Element Overview from the main menu or click on the All tab in the element manager.

  2. Select the element type for which you want to add an attribute from the list in the element manager, then click on the Attribute list button.

  3. The attribute list dialog for the selected element type will appear (see Figure 6-3). Click on the Add button in the attribute list dialog. The following new dialog will appear:

    Figure 12-2. Add attribute dialog

  4. Enter the name of the new attribute in the entry field, then click on the OK button. The entry dialog will be closed and the name of the new attribute will appear in the attribute list dialog.

  5. You can continue to add new attributes to the selected element type by clicking the Add button again. Click on the OK button when you have finished declaring new attributes for the element type in question.

The newly declared attributes are now available for all elements of the selected element type in your document.

Tip: The names of attributes that have been declared for elements in a well-formed XML document will be stored in the template for your document. They will available without the need to re-declare them for the next document that uses this document template.