DTD Overview
A DTD is the formal definition of the elements, structures, and rules for marking up a given type of SGML document. A DTD stored with a document instance must go above the instance to define the structural elements before they are encountered in the instance.
For efficiency in DTD creation and maintenance, entity declarations are often written as reusable modules, manipulated by parameters to create different versions, stored externally in separate files, and referenced by pointers in the DTD. One reason they are reusable is they have no DOCTYPE declaration attached. A few common examples of entity modules are:
• Paragraphs and running text module
• Character entities module
• Front matter elements module
• Body elements module
In this way, many varieties of DTDs can be created with minimal effort by combining the modules in different ways.
The same concept can apply to the DOCTYPE declaration. A reference is allowed immediately after the base element in the DOCTYPE declaration (see below). <!DOCTYPE doc optional reference name of external subset of DTD
If present, this reference points to an external file entity that contains what could be the rest of the DTD. The pointer is invisible (it need not be typed in) and occurs between the last end bracket (]) and the last angle bracket (>) of the internal subset to be described next. Technically speaking, this external file is called “external subset of the DTD.” In today's industrial usage, however, the term “external subset of the DTD” and “DTD” have become, in all practicality, synonymous.
Following the base element, and (if present) the reference to the external subset of the DTD, there is an “internal subset of the DTD.” Every DTD has one even if it is empty.
The DTD proper consists of two parts:
• The reference expansion of the document type declaration subset (what the parser needs)
• The embedded comments for telling anyone beyond the DTD author, what an abbreviated name for an element really means (what people need)
As you can now see, in simple cases the terms “external subset of the DTD” and “DTD” are virtually synonymous when the internal subset of the DTD is empty and the external subset of the DTD is not parameterized (the only piece left unaccounted for is the human-readable comments). If an external subset is parameterized, you can interpret the question “Are you using the same DTD?” as “Are you using the same version of the external subset of the DTD?”