HTML and CSS Reference
You might want to work through these examples to prove to yourself
that they are, in fact, correct with respect to the repetition rule.
15.4.2. Multiple Grammar Rules
By now, you can probably imagine that specifying an entire language
grammar in a single rule is difficult, although possible. Unfortunately,
the result would be an almost unreadable sequence of nearly unintel-
ligible rules. To remedy this situation, the items in a rule may them-
selves be rules containing other elements and rules. In these cases, the
items in a grammar that are themselves rules are known as nontermin-
als , and the items that are elements in the language are known as ter-
minals . Eventually, all the nonterminals must reference rules that create
sequences of terminals, or the grammar would never produce a valid
For example, we can express our sample grammar in two rules:
Document ::= A, B?, C*, Choices+, G*
Choices ::= D | E | F
In this example, Document and Choices are nonterminals, and A, B, C,
D, E, F, and G are terminals.
There is no requirement in XML (or most other grammars) that dictates
or limits the number of nonterminals in your grammar. Most grammars
use nonterminals wherever it makes sense for clarity and ease of use.
15.4.3. XML Element Grammar
The rules for defining the contents of an element match the grammar
rules we just discussed. You may use sequences, choices, groups, and
repetition to define the allowable contents of an element. The nonter-
minals in rules must be names of other elements defined in your DTD.