DTD construction features

Analysis of element and attribute declarations may be hindered if the way that DTDs use entities and marked sections is not understood.

Entities

Just as XML document authors may use general entities to aid construction of a document, DTD authors may use parameter entities to assist with the construction of a DTD. Whenever a set of attributes or a particular element model is needed in more than one place, the DTD author may use an entity to store the information in a single place, and an entity reference at each point where the information is relevant.

For example, if the Title and Para elements have the same attributes, the following may appear (the four attributes appearing in both elements):

<!ENTITY % standardAttributes  'ID       #REQUIRED
                Type   (Normal|Secret) "Normal"
                Author CDATA           #IMPLIED
                Status CDATA           "draft"' >

<!ATTLIST Title  %standardAttributes;>

<!ATTLIST Para   %standardAttributes;>

A content model can be duplicated in the same way:

<!ENTITY % textBlock  '(#PCDATA|Emph)*'>

<!ELEMENT Title  %textBlock;>

<!ELEMENT Para   %textBlock;>

Marked sections

A DTD author may use marked sections to create multiple varieties of the DTD. Specifically, parts of a DTD can be switched off and switched on, perhaps to swap between alternative models. When creating a stylesheet that must cope with all the documents that comply with a given DTD, marked sections can often be ignored.

If the stylesheet does not need to cater for elements that are not part of the application of the DTD, then all statements within marked sections that contain the IGNORE keyword (or an entity reference that is set to 'IGNORE') can be safely ignored.

<![IGNORE[
  ...
]]>

<!ENTITY % ignoreThis 'IGNORE'>

<![%ignoreThis;[
  ...
]]>

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

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