Parameter entities

Just as a document author may use a general entity to avoid unnecessary repetition, so a DTD author may use a parameter entity in a similar fashion to aid construction of the DTD. The use of entities can reduce the workload, make authoring errors less likely and clarify the DTD structure (although they can also, if used too frequently, render the DTD unintelligible).

For example, a model group that is in common use may be stored in an entity:

<!ENTITY % common  "(para | list | table)">

Within element declarations a reference is made to the parameter entity:

<!ELEMENT chapter  ((%common;)*, section*) >
<!ELEMENT section  (%common;)*>

Note that an entity reference must not be qualified by an occurrence indicator. In the example ...

Get XML Companion, The, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.