Editing an element's content model

 

+
Search Tips   |   Advanced Search

 

 

Overview

An element's content model is the representation of any data that may be contained inside an element. It represents any data that may 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).

There are four kinds of content models:

  1. element content
  2. mixed content
  3. EMPTY content
  4. ANY content

In the element content content model an element may only contain other child elements. In the mixed content content model, an element may 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 may not 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 EMTPY 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,...

  1. Open the 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 - 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 below.

    If you intend to have mixed content, the value of the first element in the 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 may 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 specify its name.

  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 related information below.

Editing a group
An element's content model is the representation of any data that may be contained inside an element. It represents any data that may 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).

Reusing external parameter entities in an element's content model
DTDs use entities to provide a mechanism to associate a name with a piece of text. Whenever you need to replace that text within a document, you can just use the name instead. There are many ways you can design entities in a DTD for reuse purposes.

 

Parent topic

Creating elements