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:
- Open your DTD in the DTD editor.
- In the Outline view, right-click the DTD
and
click Add Element.
- In the Properties view, type the new name of the element in the Name field.
- When you create an element in the DTD editor, a child element that
is EMPTY is automatically created.
- 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.
- 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.
- 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.