Sequences
In practice, a content specification that lists exactly
one child element is rare. Most elements contain either parsed
character data or (at least potentially) multiple child elements.
The simplest way to indicate multiple child elements is to separate
them with commas. This is called a sequence. It indicates that the
named elements must appear in the specified order. For example, this
element declaration says that a name element must contain exactly one
first_name child element followed
by exactly one last_name child
element:
<!ELEMENT name (first_name, last_name)>
Given this declaration, this name element is valid:
<name> <first_name>Madonna</first_name> <last_name>Cicconne</last_name> </name>
However, this one is not valid because it flips the order of two elements:
<name> <last_name>Cicconne</last_name> <first_name>Madonna</first_name> </name>
This element is invalid because it omits the last_name element:
<name> <first_name>Madonna</first_name> </name>
This one is invalid because it adds a middle_name element:
<name> <first_name>Madonna</first_name> <middle_name>Louise</middle_name> <last_name>Cicconne</last_name> </name>
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access