A SAPI DTD consists of element type declarations and their attributes. The character ends it. Between these the following are specified:
- The element name.
- Whether the element tag is optional. Two hyphens that appear after the element name mean that the start and end tags are mandatory. One hyphen followed by letter "O" indicates that the end tag can be omitted. A pair of "O" letters indicate that both the start and end tags can be omitted.
- The element content, if any. The allowed content for an element is called its content model. Element types that are designed to have no content are called empty elements. The content model for such element types is declared using the keyword "EMPTY".
The following example demonstrates a declaration of an empty element type:
| <!ELEMENT sapi:value-of - O EMPTY> |
- The element type being declared is SAPI:VALUE-OF.
- The hyphen and the following "O" indicate that the end tag can be omitted, but together with the content model "EMPTY", this is strengthened to the rule that the end tag must be omitted.
- The "EMPTY" keyword means that instances of this type must not have content.
4.3.3.1 Content Model Definitions
The content model describes what may be contained by an instance of an element type. Content model definitions may include:
- The names of allowed or forbidden element types.
- DTD entities.
- Document text (indicated by the SGML construct "#PCDATA"). The text may contain character references (see Character References). Note that they begin with “&” and end with a semicolon (e.g., "Hergé's adventures of Tintin" contains the character entity reference for the "e acute" character).
The content model of an element is specified with the following syntax:
( ... ) Delimits groups.
A | B Either A or B must occur, but not both.
A , B Either A or B must occur, in that order.
A & B Both A and B must occur, in any order.
A?A must occur zero or one time.
A*A must occur zero or more times.
A+A must occur one or more time.
Here is a sample SAPI DTD:
| <!ELEMENT sapi:exp (CDATA)> |
The SAPI:EXP element (see Element SAPI:EXP) may only contain text and character references (see Character References ); - this is indicated by the SGML data type CDATA.
Some SAPI element types use an additional SGML feature to exclude elements from their content model. Excluded elements are preceded by a hyphen. Explicit exclusions override permitted elements.