Every element used in an XML document must have an Element Declaration included in the Document Type Declarations. Element declarations have the following syntax:
<!ELEMENT name element_content >
Element declarations begin with the delimitter
<!ELEMENT and ends with the delimiter
<!ELEMENT delimiter is followed by the element name, which can be any valid XML name.
element_content defines the content of the element which can be text, child elements, empty or mixed content.
An element that contains only plain text is defined using the keyword
#PCDATA (for Parsed Character Data) inside parenthesis.
<!ELEMENT title (#PCDATA)>
Elements that contain child elements are defined by the name of the child element inside parenthesis. Multiple child elements are separated by comma.
<!ELEMENT catalog (movie)>
<!ELEMENT movie (title,year,genre,director)>
In the above example, the
catalog element is declared to contain only one child element of type
movie element contains child elements
title, year, genre, director in the exact same sequence.
To declare zero or more child elements you use the
* operator after the child element name.
<!ELEMENT catalog (movie*)>
This means the
catalog element contains zero or more child elements of type
To declare one or more child elements you use the
+ operator after the child element name.
<!ELEMENT catalog (movie+)>
This means the
catolog element must have at least one child element of type
To declare optional child elements you use the
? operator after the child element name.
<!ELEMENT movie (actor?)>
This means the movie element may or may not contain a child element of type actor
Elements that do not have any content are defined using the keyword EMPTY.
<!ELEMENT picture EMPTY>
The keyword ANY is used to declare that the element can contain any data.
<!ELEMENT catalog ANY>
The catalog element can contain any content including child elements.