DTD markup

A DTD is composed of a number of declarations. Each declaration conforms to the markup declaration format, and is classified using one of the following keywords:

  • ELEMENT (tag definition)

  • ATTLIST (attribute definitions)

  • ENTITY (entity definition)

  • NOTATION (data type notation definition).

Declarations are grouped together, and may (like entity declarations) be held within the internal subset of the document type declaration:

<!DOCTYPE MYBOOK [
<!-- The MYBOOK DTD appears here -->
<!....>
<!.......>
]>

This approach makes the DTD part of the document it describes. This can be convenient. If the document is moved, the DTD automatically moves with it, as only a single data file or stream is involved.

External subsets

But the problem with this approach is that a DTD is only worth defining if it is going to apply to a group of documents, and this technique would require the same set of declarations to be repeated in every document. This is inefficient, and also difficult to manage, as any modifications to the model must be repeated in each document. To resolve this problem, some or all of the declarations can be stored in an external subset file. This file can then be referenced from all relevant documents, by placing a URL that locates the file after the 'SYSTEM' keyword:

<!DOCTYPE MYBOOK SYSTEM "../DTDS/MYBOOK.DTD"[
  <!-- Rest of MYBOOK DTD appears here -->
  <!....>
 ]>

Of course, this is the technique previously described for handling large sets of entities. Indeed, the file referenced may contain both DTD-building declarations and entity declarations.

Internal subsets

Typically, only a few document-specific declarations are left in the internal subset, and only entity declarations at that. They may define special characters, commonly used phrases or embedded images that are not used elsewhere. In such cases, all the important document structure describing declarations are contained in the external subset file, which is why many people describe this file as the DTD file, despite the technical inaccuracy of this statement. Although it is possible to put element declarations in the internal subset, and thereby create document-specific structure models, caution is advised. DTD-specific processing software and stylesheets cannot be developed with confidence when some documents arbitrarily re-define or extend the rules.

Overriding declarations

An entity declaration in the internal subset can be used to override the value of an entity in the external subset. To understand how this is done, two important points must be recalled. The first point is that when an entity is defined more than once, only the first declaration is used. The second point is that the internal subset is processed before the external subset. Therefore, if an entity is declared in the internal subset that has the same name as one in the external subset, it will be processed first and take precedence.

In the example below, a local entity declaration is used to define the content of an element that is defined in the external subset:

<!DOCTYPE MYBOOK SYSTEM "C:DTDSMYBOOK.DTD" [
<!ENTITY % paraModel "#PCDATA | SUB | SUP">
]>

Note that this is a parameter entity, so all references to it must be in the DTD.

This technique can also be used to exert some control over the use of optional or alternative segments of the DTD, but involves the use of conditional sections, which are described later.

Attribute list declarations work in a similar way. An attribute specified in a declaration within the internal subset overrides a definition in a declaration in the external subset.

SGML Note

The SGML specification has been updated so that it also allows attribute declarations to override external declarations.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.157.186