DTD – Element Overview

The role of the DTD (Document Type Definition) is to define the legal build module of the XML document. In a DTD, the elements are declared by an element declaration.

Declare an element

In DTD, the XML element is declared by an element declaration. Element declaration uses the following syntax:

or

Empty element

The empty element is declared by category keyword EMPTY:

or

Only PCDATA elements

Only PCDATA elements are declared by #pcdata in parentheses:

Instance:

Elements with any content

By category Keyword Any declared elements, any combination of resolution data can be included:

Instance:

Elements with children (sequence)

Elements with one or more sub-elements are declared by sub-elements in parentheses:

or Instance:

When the child element declares in the sequence separated by a comma, these sub-elements must appear in the document in the same order. In a complete statement, child elements must also be declared, while the child elements can have sub-elements. The complete statement of the “NOTE” element is:

Declare only one element

Instance:

Declare minimized elements

Instance:

The plus sign (+) in the above example declares: The Message child element must appear at least once in the “Note” element.

Declaration of zero or multiple elements

Instance:

The asterisk (*) in the above example declares: child elements Message can occur zero or multiple times in the “Note” element.

Declaring zero or once elements

Instance:

The question mark (?) In the above example declares: child element Message can occur zero or once in the “Note” element.

Declare “Non … / ie …” type content

Example:

The above example declares: “Note” element must contain “to” elements, “from” elements, “header” elements, and non-“Message” elements, “Body” elements.

Disclaimer mixed content

Example: The above example declared: “Note” element can contain PCDATA, “To”, “from”, “Header”, “Note” element”Or” Message “.

Originally from: