DTD: Create elements

 

+
Search Tips   |   Advanced Search

 

 

Overview

In the DTD editor, you can create an element type declaration. This is a syntax for formally describing what an element type is and what type of data it can contain. Its basic format is: <!ELEMENT name (content-model)> , where name is the element-type and (content-model) is the type of data the element can contain.:

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

 

 

Create elements

To create an element,...

  1. Open the DTD in the DTD editor.

  2. In the Outline view, right-click the DTD Image of the DTD icon and click Add Element.

  3. In the Design 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 the 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 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)). As well, a group should not contain an EMPTY or ANY element. EMPTY or ANY elements are not legally allowed as nested entities.

Create attributes and attribute lists
In the DTD editor, you can add attribute declarations to elements. An attribute declaration is a syntax for formally declaring what an attribute type is and what type of data it can contain. Its basic format is: <attribute name attribute-type default> , where attribute-type is the type of data the attribute can contain and default is the default value of the attributes. Attributes are grouped into attribute lists. Attribute lists enable you to group together all related attributes for an element.

Editing an element's content model
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).

 

Parent topic

Editing DTDs

 

Related tasks

Deleting elements, attributes, entities, notations, and comments
Editing a group