Previous Table of Contents Next


In the following example, one model group has a long name. The name of the last element group is too long to enable the minimization delimiters to be aligned on the same line. To keep the delimiters aligned, the declaration is continued on the next line.

 <!ELEMENT  firstelm       - - (alpha, bet+)                    >
 <!ELEMENT  alpha          - - (CDATA)                          >
 <!ELEMENT  bet            - - (CDATA)                            >
 <!ELEMENT  (a|bc|cd|ef|gh|hi|lm|no|pq|rs)
                           - - (#PCDATA)  --this stays aligned-->

It is not always necessary to align all parts of declarations with such fastidiousness, particularly when you’re simply trying to get it to parse. But as you refine the DTD, and as it becomes more of a tool for your daily work, you’ll find it easiest to keep it aligned thoroughly, much as a good mechanic keeps his or her toolbox tidy and organized.

You should try to keep the following items aligned in a declaration:

  Opening delimiters of the declaration
  Element and attribute names
  Minimization delimiters
  Content model or content value declarations
  Any relevant comments or types of comments (aligning inline comments is optional but preferred)
  Closing delimiters for declarations

In other words, you should align everything in a declaration or comment that can be reasonably aligned. It’s pleasing to the eye and it makes a DTD easier to use.

Consider the comments in listing 12.2. The comments for each group of elements are aligned on the same column. Furthermore, the comments within each group are aligned. Even the line comments are aligned more or less at the end of the declaration lines.

From Here…

You have made it through the essential principles of content modeling and document analysis. You are nearly through developing the DTD.

For more information, refer to the following:

  Chapter 13, “Evaluating DTDs and Using Parsers,” tells you how to parse DTDs.
  Chapter 14, “Following Good SGML Practice,” helps you avoid some common pitfalls in an SGML installation.
  Part IV, “Markup Strategies,” helps you through more challenges, including output specifications and specialized content.


Previous Table of Contents Next