Table of Contents
This appendix shows how “monolithic” DTDs can be reorganized using some of the techniques discussed in Chapter 9, Techniques for DTD Maintenance and Readability and Chapter 10, Techniques for DTD Reuse and Customization , resulting in modularized and parameterized versions that are considerably more scalable, manageable, and customizable. The memo, letter, and report DTDs used as examples in this appendix are used by ArborText, Inc., for introductory training purposes, and are listed with ArborText's permission.
Even though the information pools of the three DTDs are very similar, they are maintained separately so that novice DTD readers can find all the relevant information in a single file. For our reorganization scenario, we'll assume that these DTDs have, over time, also begun to be used by people to produce real memos, letters, and reports. The users have made the following enhancement requests, which suggest that a restructuring of the DTDs may be beneficial:
From time to time, the various elements available in the information pool have gotten out of synchronization. Can the elements added to one DTD be added to the other two at the same time, and can all the information pools be identical to the extent possible? For example, for several months, tables in reports had a different element name from tables in letters and memos. Also, when inline graphics were added to memos and letters, they were accidentally left out of reports.
Keeping the elements synchronized would be convenient for authors who must write all three kinds of documents. It would also be useful in ensuring that text written for one kind of document could be reused in another kind of document. For example, the information on the proper use of the office's fax machine could be written up once, and then used in both the policy report kept on file and the memo initially sent to the staff. Finally, it would ease the development of processing applications for the common portion of all three document types.
Rather than having to create a separate transmittal letter to accompany reports, is it possible to make the transmittal information be part of the same document as a report?
We may need to create additional types of documents, such as proposals and statements of consulting work, and for these document types we may need different document hierarchies. Can we reuse the same information pool for all of them, to the extent possible?
A common information pool would keep those elements synchronized, and the letter model could be incorporated into the report model as a “nested DTD.” Further, the element classes and collections could be reorganized using the building-block method, which would make them easier to customize and control in each DTD.
Following are listings of the original DTDs. Example C.1, “Memo DTD Before Reorganization” shows the memo DTD, Example C.2, “Letter DTD Before Reorganization” shows the letter DTD, and Example C.3, “Report DTD Before Reorganization” shows the report DTD.
Example C.1. Memo DTD Before Reorganization
<!-- memo.dtd for ADEPT memo sample --> <!-- COMMON PUBLIC DECLARATIONS --> <!-- Public document type definition. Typical invocation: <!DOCTYPE document PUBLIC "-//ArborText//DTD Report//EN"> --> <!ENTITY % atimath PUBLIC "-//ArborText//ELEMENTS Math Equation Structures//EN"> %atimath; <!-- ArborText equation entity refs --> <!ENTITY % ATIeqn1 PUBLIC "-//ArborText//ENTITIES Equation1//EN"> %ATIeqn1; <!-- ISO Character References --> <!ENTITY % ISOpub PUBLIC "ISO 8879:1986//ENTITIES Publishing//EN"> %ISOpub; <!ENTITY % ISOnum PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN"> %ISOnum; <!ENTITY % ISOtech PUBLIC "ISO 8879:1986//ENTITIES General Technical//EN"> %ISOtech; <!ENTITY % ISOdia PUBLIC "ISO 8879:1986//ENTITIES Diacritical Marks//EN"> %ISOdia; <!ENTITY % ISOlat1 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN"> %ISOlat1; <!ENTITY % ISOlat2 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 2//EN"> %ISOlat2; <!ENTITY % ISOamso PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN"> %ISOamso; <!ENTITY % ISOgrk1 PUBLIC "ISO 8879:1986//ENTITIES Greek Letters//EN"> %ISOgrk1; <!ENTITY % ISOgrk3 PUBLIC "ISO 8879:1986//ENTITIES Greek Symbols//EN"> %ISOgrk3; <!-- COMMON ENTITY DECLARATIONS --> <!ENTITY % graphics "graphic|inline-graphic" > <!ENTITY % tables "table" > <!ENTITY % equations "inline-equation|display-equation" > <!ENTITY % par.text "#PCDATA|super|sub|emphasis" > <!ENTITY % par.text.ref "%par.text;" > <!ENTITY % par.text.note "%par.text.ref;|footnote" > <!ENTITY % par.list "sequential-list|definition-list|bulleted-list" > <!ENTITY % par.misc "computer|asis|extract" > <!ENTITY % par.fig "inline-graphic|inline-equation" > <!ENTITY % par.all "%par.text.note;| %par.list;| %par.fig;| %par.misc;" > <!ENTITY % fig.all "graphic|%tables|display-equation" > <!ENTITY % nonfig.all "graphic|display-equation" > <!ENTITY % paralevel "para|figure|%nonfig.all;" > <!-- COMMON ELEMENT DECLARATIONS --> <!ELEMENT para - - (%par.all;)* > <!ATTLIST para id ID #IMPLIED > <!ELEMENT display-equation - - (fd) > <!ATTLIST display-equation align (left|center|right) #IMPLIED > <!ELEMENT inline-equation - - (f) > <!ELEMENT computer - - (#PCDATA|footnote)* > <!ELEMENT extract - - (%par.text;|footnote)* > <!ELEMENT asis - - (%par.text;|footnote)* > <!ELEMENT title - - (%par.text.ref;)*> <!ELEMENT figure - - (title,(%fig.all;)) > <!ATTLIST figure id ID #IMPLIED > <!ELEMENT super - - (%par.text;)* -(super)> <!ELEMENT sub - - (%par.text;)* -(sub)> <!ELEMENT emphasis - - (%par.text;)* -(emphasis)> <!ELEMENT footnote - - (%par.text;)* > <!ELEMENT (bulleted-list| sequential-list) - - (title?, (item)+ ) > <!ATTLIST (bulleted-list| sequential-list) id ID #IMPLIED > <!ELEMENT definition-list - - (title?, (term, def)+) > <!ATTLIST definition-list id ID #IMPLIED > <!ELEMENT item - - (%par.text.note;|%par.list)* > <!ATTLIST item id ID #IMPLIED > <!ELEMENT term - - (%par.text.ref;)* > <!ELEMENT def - - (%par.text.note;)* > <!ELEMENT ( %graphics; ) - o EMPTY > <!ATTLIST ( %graphics; ) filename CDATA #REQUIRED processor CDATA #REQUIRED magnification NUMBER #IMPLIED horzoffsetamt CDATA #IMPLIED horzoffsetpct CDATA #IMPLIED vertoffsetamt CDATA #IMPLIED vertoffsetpct CDATA #IMPLIED cropheight CDATA #IMPLIED cropwidth CDATA #IMPLIED cropllxcoord CDATA #IMPLIED cropllycoord CDATA #IMPLIED scalefit NUMBER #IMPLIED scalefitheight CDATA #IMPLIED scalefitwidth CDATA #IMPLIED > <!-- MORE COMMON PUBLIC DECLARATIONS --> <!ENTITY % tblcon "%par.text.note;|%par.fig;|%nonfig.all;" > <!ENTITY % atitable PUBLIC "-//ArborText//ELEMENTS Table Structures//EN" > %atitable; <!-- DOCUMENT STRUCTURE --> <!ELEMENT memo - - (head,body,end) > <!-- HEAD ELEMENTS --> <!ELEMENT head - - (date, to, from, subject, cc?, (enclosure?| attachment?)) > <!ELEMENT (date, subject, enclosure, attachment) - - (%par.text;)* > <!ELEMENT (cc, to, from) - - (name, jobtitle?, organization?, address*, city?, state?, zip?, phone?, fax?)* > <!ELEMENT (name, jobtitle, organization, address, city, state, zip, phone, fax) - - (%par.text;)* > <!-- BODY ELEMENTS --> <!ELEMENT body - - (%paralevel)* > <!-- END ELEMENTS --> <!ELEMENT end - - (initials?, (enclosure|attachment)?, cc?) > <!ELEMENT initials - - (%par.text;)* >
Example C.2. Letter DTD Before Reorganization
<!-- letter.dtd for ADEPT letter sample --> <!-- COMMON PUBLIC DECLARATIONS --> <!-- Public document type definition. Typical invocation: <!DOCTYPE document PUBLIC "-//ArborText//DTD Report//EN"> --> <!ENTITY % atimath PUBLIC "-//ArborText//ELEMENTS Math Equation Structures//EN"> %atimath; <!-- ArborText equation entity refs --> <!ENTITY % ATIeqn1 PUBLIC "-//ArborText//ENTITIES Equation1//EN"> %ATIeqn1; <!-- ISO Character References --> <!ENTITY % ISOpub PUBLIC "ISO 8879:1986//ENTITIES Publishing//EN"> %ISOpub; <!ENTITY % ISOnum PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN"> %ISOnum; <!ENTITY % ISOtech PUBLIC "ISO 8879:1986//ENTITIES General Technical//EN"> %ISOtech; <!ENTITY % ISOdia PUBLIC "ISO 8879:1986//ENTITIES Diacritical Marks//EN"> %ISOdia; <!ENTITY % ISOlat1 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN"> %ISOlat1; <!ENTITY % ISOlat2 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 2//EN"> %ISOlat2; <!ENTITY % ISOamso PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN"> %ISOamso; <!ENTITY % ISOgrk1 PUBLIC "ISO 8879:1986//ENTITIES Greek Letters//EN"> %ISOgrk1; <!ENTITY % ISOgrk3 PUBLIC "ISO 8879:1986//ENTITIES Greek Symbols//EN"> %ISOgrk3; <!-- COMMON ENTITY DECLARATIONS --> <!ENTITY % graphics "graphic|inline-graphic" > <!ENTITY % tables "table" > <!ENTITY % equations "inline-equation|display-equation" > <!ENTITY % par.text "#PCDATA|super|sub|emphasis" > <!ENTITY % par.text.ref "%par.text;" > <!ENTITY % par.text.note "%par.text.ref;|footnote" > <!ENTITY % par.list "sequential-list|definition-list|bulleted-list" > <!ENTITY % par.misc "computer|asis|extract" > <!ENTITY % par.fig "inline-graphic|inline-equation" > <!ENTITY % par.all "%par.text.note;| %par.list;| %par.fig;| %par.misc;" > <!ENTITY % fig.all "graphic|%tables|display-equation" > <!ENTITY % nonfig.all "graphic|display-equation" > <!ENTITY % paralevel "para|figure|%nonfig.all;" > <!-- COMMON ELEMENT DECLARATIONS --> <!ELEMENT para - - (%par.all;)* > <!ATTLIST para id ID #IMPLIED > <!ELEMENT display-equation - - (fd) > <!ATTLIST display-equation align (left|center|right) #IMPLIED > <!ELEMENT inline-equation - - (f) > <!ELEMENT computer - - (#PCDATA|footnote)* > <!ELEMENT extract - - (%par.text;|footnote)* > <!ELEMENT asis - - (%par.text;|footnote)* > <!ELEMENT title - - (%par.text.ref;)*> <!ELEMENT figure - - (title,(%fig.all;)) > <!ATTLIST figure id ID #IMPLIED > <!ELEMENT super - - (%par.text;)* -(super)> <!ELEMENT sub - - (%par.text;)* -(sub)> <!ELEMENT emphasis - - (%par.text;)* -(emphasis)> <!ELEMENT footnote - - (%par.text;)* > <!ELEMENT (bulleted-list| sequential-list) - - (title?, (item)+ ) > <!ATTLIST (bulleted-list| sequential-list) id ID #IMPLIED > <!ELEMENT definition-list - - (title?, (term, def)+) > <!ATTLIST definition-list id ID #IMPLIED > <!ELEMENT item - - (%par.text.note;|%par.list)* > <!ATTLIST item id ID #IMPLIED > <!ELEMENT term - - (%par.text.ref;)* > <!ELEMENT def - - (%par.text.note;)* > <!ELEMENT ( %graphics; ) - o EMPTY > <!ATTLIST ( %graphics; ) filename CDATA #REQUIRED processor CDATA #REQUIRED magnification NUMBER #IMPLIED horzoffsetamt CDATA #IMPLIED horzoffsetpct CDATA #IMPLIED vertoffsetamt CDATA #IMPLIED vertoffsetpct CDATA #IMPLIED cropheight CDATA #IMPLIED cropwidth CDATA #IMPLIED cropllxcoord CDATA #IMPLIED cropllycoord CDATA #IMPLIED scalefit NUMBER #IMPLIED scalefitheight CDATA #IMPLIED scalefitwidth CDATA #IMPLIED > <!-- MORE COMMON PUBLIC DECLARATIONS --> <!ENTITY % tblcon "%par.text.note;|%par.fig;|%nonfig.all;" > <!ENTITY % atitable PUBLIC "-//ArborText//ELEMENTS Table Structures//EN" > %atitable; <!-- DOCUMENT STRUCTURE --> <!ELEMENT letter - - (head, body, end) > <!-- HEAD ELEMENTS --> <!ELEMENT head - - (date, from?, to?, subject?, salutation? ) > <!ELEMENT (date, subject, salutation) - - (%par.text;)* > <!ELEMENT (from, to) - - (name, jobtitle?, organization?, address*, city?, state?, zip?, phone?, fax?) > <!ELEMENT (name, jobtitle, organization, address, city, state, zip, phone, fax) - - (%par.text;)* > <!-- BODY ELEMENTS --> <!ELEMENT body - - (%paralevel;)* > <!-- END ELEMENTS --> <!ELEMENT end - - (closing?, sender, jobtitle?, initials?, (enclosure|attachment)?, cc?, postscript?) > <!ELEMENT (closing, sender, initials, enclosure, attachment, postscript) - - (%par.text;)* > <!ELEMENT cc - - (name, jobtitle?, organization?, address*, city?, state?, zip?, phone?, fax?) >
Example C.3. Report DTD Before Reorganization
<!-- report.dtd for ADEPT report sample --> <!-- COMMON PUBLIC DECLARATIONS --> <!-- Public document type definition. Typical invocation: <!DOCTYPE report PUBLIC "-//ArborText//DTD Report//EN"> --> <!ENTITY % atimath PUBLIC "-//ArborText//ELEMENTS Math Equation Structures//EN"> %atimath; <!-- ArborText equation entity refs --> <!ENTITY % ATIeqn1 PUBLIC "-//ArborText//ENTITIES Equation1//EN"> %ATIeqn1; <!-- ISO Character References --> <!ENTITY % ISOpub PUBLIC "ISO 8879:1986//ENTITIES Publishing//EN"> %ISOpub; <!ENTITY % ISOnum PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN"> %ISOnum; <!ENTITY % ISOtech PUBLIC "ISO 8879:1986//ENTITIES General Technical//EN"> %ISOtech; <!ENTITY % ISOdia PUBLIC "ISO 8879:1986//ENTITIES Diacritical Marks//EN"> %ISOdia; <!ENTITY % ISOlat1 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN"> %ISOlat1; <!ENTITY % ISOlat2 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 2//EN"> %ISOlat2; <!ENTITY % ISOamso PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN"> %ISOamso; <!ENTITY % ISOgrk1 PUBLIC "ISO 8879:1986//ENTITIES Greek Letters//EN"> %ISOgrk1; <!ENTITY % ISOgrk3 PUBLIC "ISO 8879:1986//ENTITIES Greek Symbols//EN"> %ISOgrk3; <!-- COMMON ENTITY DECLARATIONS --> <!ENTITY % par.text "#PCDATA|super|sub|emphasis" > <!ENTITY % par.text.ref "%par.text;|xref" > <!ENTITY % par.text.note "%par.text.ref;|footnote" > <!ENTITY % par.list "list|sequential-list|definition-list|bulleted-list" > <!ENTITY % par.misc "computer|asis|extract" > <!ENTITY % par.fig "graphic|table|inline-equation|display-equation" > <!ENTITY % par.all "%par.text.note;| %par.list;| %par.fig;| %par.misc;" > <!ENTITY % fig.all "graphic|table|display-equation" > <!ENTITY % paralevel "para|figure" > <!-- COMMON ELEMENT DECLARATIONS --> <!ELEMENT para - - (%par.all;)* > <!ATTLIST para id ID #IMPLIED > <!ELEMENT display-equation - - (fd) > <!ELEMENT inline-equation - - (f) > <!ELEMENT commentary - - (%par.text;)* > <!ELEMENT computer - - (#PCDATA | footnote )* > <!ELEMENT extract - - (%par.text; | footnote )* > <!ELEMENT asis - - (%par.text; | footnote )* > <!ELEMENT title - - (%par.text.ref;)*> <!ELEMENT figure - - (title, (%fig.all;) ) > <!ATTLIST figure id ID #IMPLIED > <!ELEMENT super - - (%par.text;)* -(super)> <!ELEMENT sub - - (%par.text;)* -(sub)> <!ELEMENT emphasis - - (%par.text;)* -(emphasis)> <!ELEMENT footnote - - ((author?, title, publisher?, date?, page?)|commentary ) > <!ELEMENT bib-entry - - (author?, title, publisher?, date?, page? ) > <!ELEMENT (publisher|page) - - (%par.text;)* > <!ELEMENT (list| sequential-list| bulleted-list) - - (title?, (item)+ ) > <!ATTLIST (list|sequential-list|bulleted-list) id ID #IMPLIED > <!ELEMENT definition-list - - (title?, (term, def)+) > <!ATTLIST definition-list id ID #IMPLIED > <!ELEMENT item - - (%par.text.note;|%par.list)* > <!ATTLIST item id ID #IMPLIED > <!ELEMENT term - - (%par.text.ref;)* > <!ELEMENT def - - (%par.text.note;)* > <!ELEMENT graphic - O EMPTY > <!ATTLIST graphic filename CDATA #REQUIRED processor CDATA #REQUIRED magnification NUMBER #IMPLIED horzoffsetamt CDATA #IMPLIED horzoffsetpct CDATA #IMPLIED vertoffsetamt CDATA #IMPLIED vertoffsetpct CDATA #IMPLIED cropheight CDATA #IMPLIED cropwidth CDATA #IMPLIED cropllxcoord CDATA #IMPLIED cropllycoord CDATA #IMPLIED scalefit NUMBER #IMPLIED scalefitheight CDATA #IMPLIED scalefitwidth CDATA #IMPLIED > <!ELEMENT xref - O EMPTY > <!ATTLIST xref xrefid IDREF #REQUIRED > <!-- MORE COMMON PUBLIC DECLARATIONS --> <!ENTITY % tblcon "%par.text;|graphic|inline-equation" > <!ENTITY % atitable PUBLIC "-//ArborText//ELEMENTS Table Structures//EN" > %atitable; <!-- DOCUMENT STRUCTURE --> <!ELEMENT report - - (front,body,rear?) > <!-- FRONT ELEMENTS --> <!ELEMENT front - - (title-info, author-info, contents? ) > <!ELEMENT title-info - - (title, subtitle?, version?, revision?, date) > <!ELEMENT author-info - - ((author, authloc?)+) > <!ELEMENT contents - O EMPTY > <!ELEMENT (subtitle| version| revision| author| authloc| date) - - (%par.text;)* > <!-- BODY ELEMENTS --> <!ELEMENT body - - (section*) > <!ELEMENT section - - (title, (%paralevel;)*, topic* )> <!ATTLIST section id ID #IMPLIED> <!ELEMENT topic - - (title, (%paralevel;)*, subtop* )> <!ATTLIST topic id ID #IMPLIED> <!ELEMENT subtop - - (title, (%paralevel;)* )> <!ATTLIST subtop id ID #IMPLIED > <!-- REAR ELEMENTS --> <!ELEMENT rear - - (appendix*, bibliography?, glossary? ) > <!ELEMENT appendix - - (title, (%paralevel)* ) > <!ATTLIST appendix id ID #IMPLIED> <!ELEMENT glossary - - (title, (para|definition-list)+ ) > <!ELEMENT bibliography - - (title, (bib-entry)+ ) > ]>
Figure C.1, “Original Structure of the Memo, Letter, and Report DTDs” represents the structure of the original DTDs. The use of table and equation DTD fragments is done modularly, but otherwise the DTDs are separate (though large portions of them are nearly identical).
Figure C.2, “Modified Structure of the Memo, Letter, and Report DTDs” represents the overall structure of the DTDs as modified for the new goals. All three use an information pool module, and a module for metainformation (the elements that describe the senders and recipients of memos and letters) has been added as well. Letters can be nested within reports or can be created separately.
The following sections list and describe the new modules. The sections proceed approximately from the top down, even though the parameter entities containing the modules must be referenced from the bottom up.
Note that element name indirection hasn't been used in this reorganization. Using parameter entities to represent element names would be a good idea for maintenance reasons if any names at the lower levels are anticipated to change in the future.
Figure C.2, “Modified Structure of the Memo, Letter, and Report DTDs” is actually a simplified picture of the structure of the DTD modules. Each DTD needs a top-level “driver file” that pulls in all the other necessary modules, including modules for the respective document hierarchies. The hierarchy modules can't be combined with the top-level driver files because of potential problems with the letter/report nested document type: If the same file serves as the letter hierarchy module and the top-level driver file, it will need to reference all the lower-level modules that are needed. Then, when the report DTD references the single high-level letter file, it will also reference duplicates of the modules it already needs for its own structure independently of letters. Since element declarations cannot be duplicated in a DTD, errors will be reported by parsers.
If, in order to avoid the errors, the report DTD file simply relied on the modules as referenced by the letter file, then it would not be possible to use different information pools for the reports and letters (if this were desired).
A more precise schematic of the module relationships is as shown in Figure C.3, “Precise Modular Relationships of the Reorganized Memo, Letter, and Report DTDs”.
Example C.4, “New Memo DTD Driver File” shows the top-level memo DTD driver file that references various other modules and customizes them. In this case, no customizations are necessary. Notice that the “memo module” that is referenced contains only the overall hierarchy for memos, not any of the information pool material.
Example C.4. New Memo DTD Driver File
<!-- .................... memo DTD ........................................ --> <!-- .................... character entity sets ........................... --> <!ENTITY % atimath PUBLIC "-//ArborText//ELEMENTS Math Equation Structures//EN"> %atimath; <!-- ArborText equation entity refs --> <!ENTITY % ATIeqn1 PUBLIC "-//ArborText//ENTITIES Equation1//EN"> %ATIeqn1; <!-- ISO Character References --> <!ENTITY % ISOpub PUBLIC "ISO 8879:1986//ENTITIES Publishing//EN"> %ISOpub; <!ENTITY % ISOnum PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN"> %ISOnum; <!ENTITY % ISOtech PUBLIC "ISO 8879:1986//ENTITIES General Technical//EN"> %ISOtech; <!ENTITY % ISOdia PUBLIC "ISO 8879:1986//ENTITIES Diacritical Marks//EN"> %ISOdia; <!ENTITY % ISOlat1 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN"> %ISOlat1; <!ENTITY % ISOlat2 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 2//EN"> %ISOlat2; <!ENTITY % ISOamso PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN"> %ISOamso; <!ENTITY % ISOgrk1 PUBLIC "ISO 8879:1986//ENTITIES Greek Letters//EN"> %ISOgrk1; <!ENTITY % ISOgrk3 PUBLIC "ISO 8879:1986//ENTITIES Greek Symbols//EN"> %ISOgrk3; <!-- .................... customizations .................................. --> <!--(change to INCLUDE if need to redefine info pool mixtures using classes)--> <!ENTITY % redefine "IGNORE"> <!-- .................... lower-level modules ............................. --> <!ENTITY % pool PUBLIC "-//ArborText//ELEMENTS Information Pool//EN"> %pool; <!ENTITY % meta PUBLIC "-//ArborText//ELEMENTS Metainformation//EN"> %meta; <!ENTITY % memomod PUBLIC "-//ArborText//ELEMENTS Basic Memo Module//EN"> %memomod; <!-- .................... end of memo DTD ................................. -->
The main file for the letter DTD looks similar to that for the memo DTD; it is shown in Example C.5, “New Letter DTD Driver File”.
Example C.5. New Letter DTD Driver File
<!-- .................... letter DTD ...................................... --> <!-- .................... character entity sets ........................... --> <!ENTITY % atimath PUBLIC "-//ArborText//ELEMENTS Math Equation Structures//EN"> %atimath; <!-- ArborText equation entity refs --> <!ENTITY % ATIeqn1 PUBLIC "-//ArborText//ENTITIES Equation1//EN"> %ATIeqn1; <!-- ISO Character References --> <!ENTITY % ISOpub PUBLIC "ISO 8879:1986//ENTITIES Publishing//EN"> %ISOpub; <!ENTITY % ISOnum PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN"> %ISOnum; <!ENTITY % ISOtech PUBLIC "ISO 8879:1986//ENTITIES General Technical//EN"> %ISOtech; <!ENTITY % ISOdia PUBLIC "ISO 8879:1986//ENTITIES Diacritical Marks//EN"> %ISOdia; <!ENTITY % ISOlat1 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN"> %ISOlat1; <!ENTITY % ISOlat2 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 2//EN"> %ISOlat2; <!ENTITY % ISOamso PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN"> %ISOamso; <!ENTITY % ISOgrk1 PUBLIC "ISO 8879:1986//ENTITIES Greek Letters//EN"> %ISOgrk1; <!ENTITY % ISOgrk3 PUBLIC "ISO 8879:1986//ENTITIES Greek Symbols//EN"> %ISOgrk3; <!-- .................... customizations .................................. --> <!--(change to INCLUDE if need to redefine info pool mixtures using classes)--> <!ENTITY % redefine "IGNORE"> <!-- .................... lower-level modules ............................. --> <!ENTITY % pool PUBLIC "-//ArborText//ELEMENTS Information Pool//EN"> %pool; <!ENTITY % meta PUBLIC "-//ArborText//ELEMENTS Metainformation//EN"> %meta; <!ENTITY % lettermod PUBLIC "-//ArborText//ELEMENTS Basic Letter Module//EN"> %lettermod; <!-- .................... end of letter DTD ............................... -->
The main file for the report DTD is a little more complex because it redefines some parameter entities in the lower-level modules in order to extend the list of available elements. While memo and letter content can be reused in reports, report text may not be able to be reused in memos and letters, since reports allow more elements in the information pool. The report main file contains two document hierarchy modules: one for letters (which requires that the metainformation module be included before it) and one for reports. The file is shown in Example C.6, “New Report DTD Driver File”.
Example C.6. New Report DTD Driver File
<!-- .................... report DTD ...................................... --> <!-- .................... character entity sets ........................... --> <!ENTITY % atimath PUBLIC "-//ArborText//ELEMENTS Math Equation Structures//EN"> %atimath; <!-- ArborText equation entity refs --> <!ENTITY % ATIeqn1 PUBLIC "-//ArborText//ENTITIES Equation1//EN"> %ATIeqn1; <!-- ISO Character References --> <!ENTITY % ISOpub PUBLIC "ISO 8879:1986//ENTITIES Publishing//EN"> %ISOpub; <!ENTITY % ISOnum PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN"> %ISOnum; <!ENTITY % ISOtech PUBLIC "ISO 8879:1986//ENTITIES General Technical//EN"> %ISOtech; <!ENTITY % ISOdia PUBLIC "ISO 8879:1986//ENTITIES Diacritical Marks//EN"> %ISOdia; <!ENTITY % ISOlat1 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN"> %ISOlat1; <!ENTITY % ISOlat2 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 2//EN"> %ISOlat2; <!ENTITY % ISOamso PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN"> %ISOamso; <!ENTITY % ISOgrk1 PUBLIC "ISO 8879:1986//ENTITIES Greek Letters//EN"> %ISOgrk1; <!ENTITY % ISOgrk3 PUBLIC "ISO 8879:1986//ENTITIES Greek Symbols//EN"> %ISOgrk3; <!-- .................... customizations .................................. --> <!-- these entities are read before the modules, so take precedence --> <!--(extend annotation class with bibliographic citation footnote)--> <!ENTITY % local.annots "|citation"> <!--(add new local.xrefs class)--> <!ENTITY % local.xrefs "xref"> <!--(define content model for citations and bibliographic entries)--> <!ENTITY % bib.model "author?, title, publisher?, date?, page?"> <!--(extend list class with simple list)--> <!ENTITY % local.lists "|list"> <!--(extend data mixtures with local.xrefs)--> <!ENTITY % local.computer.data.mix "|%local.xrefs;"> <!ENTITY % local.normal.data.mix "|%local.xrefs;"> <!ENTITY % local.title.data.mix "|%local.xrefs;"> <!ENTITY % local.table.data.mix "|%local.xrefs;"> <!ENTITY % local.para.data.mix "|%local.xrefs;"> <!--(change to INCLUDE if need to redefine info pool mixtures using classes)--> <!ENTITY % redefine "IGNORE"> <!-- .................... inclusion of standard modules ................... --> <!ENTITY % pool PUBLIC "-//ArborText//ELEMENTS Information Pool//EN"> %pool; <!ENTITY % meta PUBLIC "-//ArborText//ELEMENTS Metainformation//EN"> %meta; <!ENTITY % letter PUBLIC "-//ArborText//ELEMENTS Basic Letter Module//EN"> %letter; <!ENTITY % reportmod PUBLIC "-//ArborText//ELEMENTS Basic Report Module//EN"> %reportmod; <!-- .................... new information pool elements ................... --> <!ELEMENT citation - - (%bib.model;)> <!--(citation contents defined in report module, with bib-entry)--> <!ELEMENT list - - (%list.model;)> <!ATTLIST list id ID #IMPLIED > <!ELEMENT xref - o EMPTY> <!ATTLIST xref xrefid IDREF #REQUIRED > <!-- .................... end of report DTD .............................. -->
The document hierarchy modules for the three DTDs are relatively simple. They define only the high-level structures that make each document type unique, and leave the actual contents to the metainformation and information pool modules.
The memo hierarchy module is shown in Example C.7, “Memo Hierarchy Module”. Notice that it defines its own unique element collection, % memobody.mix;
, by using element class entities defined in the information pool.
Example C.7. Memo Hierarchy Module
<!-- .................... memo hierarchy module ........................... --> <!-- .................... memo mixtures ................................... --> <!--building blocks and mixtures are defined in information pool module --> <!ENTITY % memobody.mix "%paras;|%displays;|%formals;"> <!-- .................... memo structure .................................. --> <!-- unmentioned elements are defined in metainfo module --> <!ELEMENT memo - - (head, body, end)> <!ELEMENT head - - (date, to, from, subject, cc?, (enclosure|attachment)?)> <!ELEMENT body - - (%memobody.mix;)*> <!ELEMENT end - - (initials?, (enclosure|attachment)?, cc?)> <!-- .................... memo metainformation ............................ --> <!-- content model and other elements are defined in metainfo module --> <!ELEMENT cc - - (%contact.model;)*> <!ELEMENT from - - (%contact.model;)*> <!ELEMENT to - - (%contact.model;)*> <!-- .................... end of memo hierarchy module .................... -->
The letter hierarchy module is shown in Example C.8, “Letter Hierarchy Module”. It is somewhat similar to the memo hierarchy. Notice how it uses the %contact.model;
parameter entity to define slightly different content models for the cc
, from
, and to
elements compared to the definitions in the memo module; the fact that their models are different explains why these elements aren't defined in the metainformation module. Instead, the common part of the model is in a parameter entity, which the memo and letter hierarchy modules can choose to use in defining their own versions of these elements. If letters and memos could appear in the same document (which they currently cannot), the different content models would conflict.
Example C.8. Letter Hierarchy Module
<!-- .................... letter hierarchy module ......................... --> <!-- .................... letter mixtures ................................. --> <!-- building blocks and mixtures are defined in information pool module --> <!ENTITY % letterbody.mix "%paras;|%displays;|%formals;"> <!-- .................... letter structure ................................ --> <!-- unmentioned elements are defined in metainfo module --> <!ELEMENT letter - - (head, ltrbody, end)> <!ELEMENT head - - (date, from?, to?, subject?, salutation?)> <!ELEMENT ltrbody - - (%letterbody.mix;)*> <!ELEMENT end - - (closing?, sender, jobtitle?, initials?, (enclosure|attachment)?, cc?, postscript?)> <!-- .................... letter metainformation .......................... --> <!-- content model and other elements are defined in metainfo module --> <!ELEMENT cc - - (%contact.model;)> <!ELEMENT from - - (%contact.model;)> <!ELEMENT to - - (%contact.model;)> <!-- .................... end of letter hierarchy module .................. -->
The report hierarchy module is shown in Example C.9, “Report Hierarchy Module”. It mentions the letter
element, which is why the letter hierarchy module must be included in the report DTD.
Example C.9. Report Hierarchy Module
<!-- .................... report hierarchy module ......................... --> <!-- .................... report mixtures ................................. --> <!-- building blocks and mixtures are defined in information pool module --> <!ENTITY % reportbody.mix "%paras;|%displays;|%formals;|%tables;"> <!-- .................... report structure ................................ --> <!-- other elements are defined in information pool/metainfo modules --> <!ELEMENT report - - (letter?, front, body, rear)> <!-- letter (defined in letter DTD)--> <!-- .................... front matter --> <!ELEMENT front - - (title-info, author-info, contents?)> <!ELEMENT title-info - - (title, subtitle?, version?, revision?, date)> <!ELEMENT (subtitle, version, revision) - - (%simple.data.mix;)*> <!ELEMENT author-info - - (author, authloc?)+> <!ELEMENT (author, authloc) - - (%simple.data.mix;)*> <!ELEMENT contents - o EMPTY> <!-- .................... report body --> <!ELEMENT body - - (section*)> <!ELEMENT section - - (title, (%reportbody.mix;)*, topic*)> <!ATTLIST section id ID #IMPLIED > <!ELEMENT topic - - (title, (%reportbody.mix;)*, subtop*)> <!ATTLIST topic id ID #IMPLIED > <!ELEMENT subtop - - (title, (%reportbody.mix;)*)> <!ATTLIST subtop id ID #IMPLIED > <!-- .................... rear matter --> <!ELEMENT rear - - (appendix*, bibliography?, glossary?)> <!ELEMENT appendix - - (title, (%reportbody.mix;)*)> <!ATTLIST appendix id ID #IMPLIED > <!ELEMENT glossary - - (title, (para|definition-list)+)> <!ELEMENT bibliography - - (title, bib-entry+)> <!ELEMENT bib-entry - - (%bib.model;)> <!ELEMENT (publisher, page) - - (%simple.data.mix;)*> <!-- .................... end of report hierarchy module ................. -->
The memo and letter hierarchy modules have a great deal of metainformation in common, and this metainformation could be said to help define them as document types, suggesting that perhaps the metainformation “belongs” in the hierarchy modules. The reason why these elements are in a separate module is that they are shared between the two DTDs; referencing them helps them be maintained more consistently.
The metainformation module is shown in Example C.10, “Memo and Letter Metainformation Module”. Notice that, for convenience of lookup, the elements are simply alphabetized, since their usage in any one document hierarchy might be in a different order from their usage in any other. Notice also that, because the content models use an element collection that is set up in the
information pool (%simple.data.mix;
), the information pool module must be referenced before the metainformation module.
Example C.10. Memo and Letter Metainformation Module
<!-- .................... memo/letter metainformation ..................... --> <!-- .................... content models .................................. --> <!ENTITY % contact.model "name, jobtitle?, organization?, address*, city?, state?, zip?, phone?, fax?"> <!-- .................... elements ........................................ --> <!-- mixtures are defined in information pool module --> <!ELEMENT address - - (%simple.data.mix;)*> <!ELEMENT attachment - - (%simple.data.mix;)*> <!ELEMENT city - - (%simple.data.mix;)*> <!ELEMENT closing - - (%simple.data.mix;)*> <!ELEMENT date - - (%simple.data.mix;)*> <!ELEMENT enclosure - - (%simple.data.mix;)*> <!ELEMENT fax - - (%simple.data.mix;)*> <!ELEMENT initials - - (%simple.data.mix;)*> <!ELEMENT jobtitle - - (%simple.data.mix;)*> <!ELEMENT name - - (%simple.data.mix;)*> <!ELEMENT organization - - (%simple.data.mix;)*> <!ELEMENT phone - - (%simple.data.mix;)*> <!ELEMENT postscript - - (%simple.data.mix;)*> <!ELEMENT salutation - - (%simple.data.mix;)*> <!ELEMENT sender - - (%simple.data.mix;)*> <!ELEMENT state - - (%simple.data.mix;)*> <!ELEMENT subject - - (%simple.data.mix;)*> <!ELEMENT zip - - (%simple.data.mix;)*> <!-- .................... end of memo/letter metainformation .............. -->
The information pool is used in uncustomized form for memos and letters. It is extended only for use in reports (as Example C.6, “New Report DTD Driver File” shows). All the lower-level element class and collection entities are set up in the information pool module, as well as a parameter entity for the content model of lists that was found to be useful for an extension element in reports. Table C.1, “Information Unit Classes and Collections” and Table C.2, “Data-Level Classes and Collections” show summaries of the element classes and collections.
Table C.2. Data-Level Classes and Collections
Contexts | para | simple | computer | normal |
---|---|---|---|---|
Contents | ||||
#PCDATA | X | X | X | X |
Emphasized Text: | X | X | X | |
super | ||||
sub | ||||
emphasis | ||||
Inline Figures: | X | |||
inline-graphic | ||||
inline-equation | ||||
Annotations: | X | X | X | |
footnote | ||||
title | table | footnote | ||
#PCDATA | X | X | X | |
Emphasized Text: | X | X | X | |
super | ||||
sub | ||||
emphasis | ||||
Inline Figures: | ||||
inline-graphic | ||||
inline-equation | ||||
Annotations: | X | X | ||
footnote |
The information pool module is shown in Example C.11, “Information Pool Module”. Notice that between the entity declarations for classes and collections, an inactive“redefinition” entity definition and reference appears. This entity is a placeholder for a file containing any entity declarations that must use existing element classes in overriding the existing element
collections. (If the %local.xxx.mix;
entities had not been provided on the element collection entities, the redefinition placeholder would have had to be used in order to add the xref
element that appears in reports.)
Example C.11. Information Pool Module
<!-- .................... information pool ................................ --> <!-- .................... common entities ................................. --> <!-- .................... classes for information units --> <!ENTITY % local.paras ""> <!ENTITY % paras "para %local.paras;"> <!ENTITY % local.blocks ""> <!ENTITY % blocks "computer|extract|asis %local.blocks;"> <!ENTITY % local.lists ""> <!ENTITY % lists "bulleted-list|definition-list|sequential-list %local.lists;"> <!ENTITY % local.displays ""> <!ENTITY % displays "graphic|display-equation %local.displays;"> <!ENTITY % local.tables ""> <!ENTITY % tables "table %local.tables;"> <!ENTITY % local.formals ""> <!ENTITY % formals "figure %local.formals;"> <!--(annots is also used in data mixtures)--> <!ENTITY % local.annots ""> <!ENTITY % annots "footnote %local.annots;"> <!-- .................... classes for data-level elements --> <!ENTITY % local.emphs ""> <!ENTITY % emphs "super|sub|emphasis %local.emphs;"> <!ENTITY % local.inlinefigs ""> <!ENTITY % inlinefigs "inline-graphic|inline-equation %local.inlinefigs;"> <!-- .................... redefinition module --> <![ %redefine; [ <!ENTITY % redefmod PUBLIC "-//ArborText//ENTITIES Entity Redefinitions//EN"> %redefmod; ]]> <!-- .................... collections for information unit contexts --> <!-- names with "iu." in them also have "data." counterparts --> <!ENTITY % local.item.mix ""> <!ENTITY % item.mix "%lists; %local.item.mix;"> <!ENTITY % local.para.iu.mix ""> <!ENTITY % para.iu.mix "%blocks;|%lists;|%tables;|graphic %local.para.iu.mix;"> <!ENTITY % local.figure.mix ""> <!ENTITY % figure.mix "%displays;|%tables; %local.figure.mix;"> <!ENTITY % local.table.iu.mix ""> <!ENTITY % table.iu.mix "%displays; %local.table.iu.mix;"> <!-- .................... collections for data-level contexts --> <!ENTITY % local.ftnt.data.mix ""> <!ENTITY % ftnt.data.mix "#PCDATA|%emphs; %local.ftnt.data.mix;"> <!ENTITY % local.simple.data.mix ""> <!ENTITY % simple.data.mix "#PCDATA|%emphs; %local.simple.data.mix;"> <!ENTITY % local.computer.data.mix ""> <!ENTITY % computer.data.mix "#PCDATA |%annots; %local.computer.data.mix;"> <!ENTITY % local.normal.data.mix ""> <!ENTITY % normal.data.mix "#PCDATA|%emphs; |%annots; %local.normal.data.mix;"> <!ENTITY % local.title.data.mix ""> <!ENTITY % title.data.mix "#PCDATA|%emphs; |%annots; %local.title.data.mix;"> <!ENTITY % local.table.data.mix ""> <!ENTITY % table.data.mix "#PCDATA|%emphs; |%annots; %local.table.data.mix;"> <!ENTITY % local.para.data.mix ""> <!ENTITY % para.data.mix "#PCDATA|%emphs;|%inlinefigs;|%annots; %local.para.data.mix;"> <!-- .................... content models --> <!ENTITY % list.model "title?, (item+)"> <!-- .................... information unit elements ....................... --> <!ELEMENT title - - (%title.data.mix;)*> <!ELEMENT para - - (%para.iu.mix;|%para.data.mix;)*> <!ATTLIST para id ID #IMPLIED > <!ELEMENT computer - - (%computer.data.mix;)*> <!ELEMENT extract - - (%normal.data.mix;)*> <!ELEMENT asis - - (%normal.data.mix;)*> <!ELEMENT (bulleted-list, sequential-list) - - (%list.model;)> <!ELEMENT item - - (%item.mix;|%normal.data.mix;)*> <!ELEMENT definition-list - - (title?, (term, def)+)> <!ELEMENT term - - (%title.data.mix;)*> <!ELEMENT def - - (%normal.data.mix;)*> <!ELEMENT (graphic, inline-graphic) - o EMPTY> <!ATTLIST (graphic, inline-graphic) filename CDATA #REQUIRED processor CDATA #REQUIRED magnification NUMBER #IMPLIED horzoffsetamt CDATA #IMPLIED horzoffsetpct CDATA #IMPLIED vertoffsetamt CDATA #IMPLIED vertoffsetpct CDATA #IMPLIED cropheight CDATA #IMPLIED cropwidth CDATA #IMPLIED cropllxcoord CDATA #IMPLIED cropllycoord CDATA #IMPLIED scalefit NUMBER #IMPLIED scalefitheight CDATA #IMPLIED scalefitwidth CDATA #IMPLIED > <!--ELEMENT table (declared in ATI table module, below)--> <!--(tblcon is required to be defined by ATI table module)--> <!ENTITY % tblcon "%table.iu.mix;|%table.data.mix;"> <!ELEMENT display-equation - - (fd)> <!ATTLIST display-equation align (left |center |right) #IMPLIED > <!-- fd (defined in ATI math module)--> <!--(note that only one element is allowed as figure main content)--> <!ELEMENT figure - - (title, (%figure.mix;))> <!ATTLIST figure id ID #IMPLIED > <!ELEMENT footnote - - (commentary)> <!ELEMENT commentary - - (%ftnt.data.mix;)*> <!-- .................... data-level elements ............................. --> <!ELEMENT super - - (%normal.data.mix;)* -(super)> <!ELEMENT sub - - (%normal.data.mix;)* -(sub)> <!ELEMENT emphasis - - (%normal.data.mix;)* -(emphasis)> <!--ELEMENT inline-graphic (defined with graphic above)--> <!ELEMENT inline-equation - - (f)> <!--ELEMENT f (defined in ATI math module)--> <!-- .................... standard DTD fragments .......................... --> <!-- these are here to catch any parameter entities defined above --> <!ENTITY % table PUBLIC "-//ArborText//ELEMENTS Table Structures//EN"> %table; <!ENTITY % math PUBLIC "-//ArborText//ELEMENTS Math Equation Structures//EN"> %math; <!-- .................... end of information pool ......................... -->
This modularization and parameterization process required a few changes to the markup model:
Footnotes in reports and the other two document types originally had different definitions. In order to make the original footnote
element in reports be consistent across all three, a commentary
child element must now be supplied. A new child element in footnotes, citation
, has been added to the content model of footnotes in reports to contain bibliographic citation information.
The body
element in letters conflicted with the element of the same name in reports, so it has been renamed to ltrbody
.
These are both backwards-incompatible changes, but they are relatively minor, and legacy documents can easily be transformed to conform to the new DTD if necessary.