Editing an element's content model

An element's content model represents any data that can be contained inside or within the content of an element (that is, between the start and end tags of an element in an XML file). Editing an element's content model enables you to determine exactly what the element can (and cannot) contain.

There are four kinds of content models: element content, mixed content, EMPTY content and ANY content

In the element content content model an element can only contain other child elements. In the mixed content content model, an element can contain both character data (text that is not parsed by the XML parser) and other child elements. In the EMPTY content content model, an element cannot contain any other elements or text. In the ANY content content model, the element can literally contain anything - other elements, in any number, and text.

In the DTD editor, you can create elements with any of these content models. When you create an element in the DTD editor, a child element with an EMPTY content model is automatically created.

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

To edit an element's content model, follow these steps:

  1. Open your DTD in the DTD editor.
  2. In the Outline view, expand the parent element you want to work with.
  3. Select the first child of the expanded parent element. This is the element's content model.
  4. In the Design view, you change its Content type to
    • ANY
    • (#PCDATA)
    • Another element
    • Children Content or Mixed Content.
    Once you select either Children Content or Mixed Content you will have a group (represented by a group node - This graphic is the Mixed Content group node if you select Children Content and This graphic is the Children Content group node 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.

    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).

  5. If you do not want the parent element to contain anything, leave its Content type as EMPTY.
  6. Select the appropriate Occurrence option to indicate how often the element can occur in an XML file. This option is not available if you select ANY, (#PCDATA), EMPTY, or another element.
  7. To add another existing element to a group as a child, right-click the group node, click Add Element to Content Model and select it.
  8. To add a group to the content model, right-click the group node and click Add Group to Content Model. For information on editing a group, refer to the link below.

Feedback