Debugging the DTD

Model editing

There is often a number of different ways that the legal content of an element can be specified. But in all cases, the most terse and efficient alternative should be chosen, as this approach reduces ambiguity. The following is a list of some of the most common mistakes:

good practice               bad practice

(a+)            instead of  (a, a*)
(a*)            instead of  (a?, a*)
(a | b)?        instead of  (a? | b?)
(a, b, c, d)    instead of  (a, (b, c), d)
(a, b?, c?, d)  instead of  (a, (b?, c?)?, d)
((a | b), c)    instead of  ((a, c) | (b, c))

Badly designed models have been seen in many publicly released DTDs. They cause confusion because they tend to imply that some other model was intended, and cast doubt on the quality of the model itself.

Syntax testing ...

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.