# Creating elements

You can use element declarations in DTDs to define the elements that may occur in an XML document. Element declarations can specify that an element can contain other elements, that it can contain anything at all, or that it must be empty.

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

Creating elements

To create an element, follow these steps:

1. Open your DTD in the DTD editor.
2. In the Outline view, right-click the DTD and click Add Element.
3. In the Properties view, type the new name of the element in the Name field.
4. When you create an element in the DTD editor, a child element that is EMPTY is automatically created.
   1. Select the EMPTY child element and, in the Properties view, change its Content type to ANY, (#PCDATA), or another element. If you do not want the parent element to contain anything, leave its content model type as EMPTY.
   2. If you want your parent element to contain more than one child element (or mixed content), select Children Content or Mixed Content from the Content type list. Once you select either of these, you will have a group (represented by a group node - if you select Children Content and if you select Mixed Content), which you can use to create a group of child elements under the parent element. A child element will automatically be created under the group node. For information on editing a group, refer to the related information.
5. Click the Documentation tab if you want to provide any information about this element. The Documentation page is used for human readable material, such as a description of the element.

Note: If you intend to have mixed content, the value of the first element in your group must be (#PCDATA) (consequently, if you select Mixed Content, two child elements will automatically be created, the first one having a value of (#PCDATA)). As well, a group should not contain an EMPTY or ANY element. EMPTY or ANY elements are not legally allowed as nested entities.

Related tasks
Creating attributes and attribute lists
Editing an element's content model
Editing a group node
Deleting elements, attributes, entities, notations, and comments

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