Home > Projects > DTM

Background
DOCTYPE Declaration
DTD Hierarchy
Examples
Including Character Data
Generating XHTML
Project Files

The Document Type Model DTD

Background Info

The DTD for the Document Type Model (DTM) is derived from two sources:

The DTM DTD is an amalgamation of the these two sources. It serves two purposes: (1) it documents the process of Document Type Modeling as discussed by Maler and El Andaloussi, and (2) also serves as the source of reference documentation for a DTD that can be generated using the included XSL stylesheets, see the section on generating XHTML for more information on how to do this.

DOCTYPE Declaration

The DOCTYPE Declaration to use in DTM instance is:

     
     <!DOCTYPE model PUBLIC "-//EPRG//DTD DocModel XML V1.0//EN"
          "http://www.isrl.uiuc.edu/~kmreiss/projects/dtdmodel/model.dtd">
     

The root element of the DTM DTD is <model>. Any DTD-aware XML editor will greatly simplify your construction of a DTM instance. My editor of choice is the PSGML SGML/XML mode for emacs.

DTM Hierarchy

The basic hierarchy of the DTM DTD

DTM Hierarchy Chart

Two elements follow as children of the root <model> element, <modelDesc> and <tagset>. The <modelDesc> element contains sub-elements that contain meta-information about the DTM. <tagset> is a container element for a an individual description of element and parameter entity class that is part of the DTM. See the documentation for an explanation of and example use case for each element and entity class in the DTD. The full DTD can be found in the file model.dtd.

Examples

Two sample document instances are available that have been encoding using the Document Type Model DTD to serve as a guide for the creation of your own DTM. One is documentation for a simple poem DTD. The example files for week 4's presentation can be found at this location. The sample document instance that contains the DTM for this DTD is called poemdoc.xml.

The second sample document instance is called modeldoc.xml. This much longer document instance contains a DTM for the elements and entity classes used to create the DTM DTD itself. This file is a self-documenting example of every element that can appear in instances encoded with the DTM DTD.

Example DTM Instances:

Including Character Data

One issue which will come up is the incorporation of example markup fragments into a document instance, since the inclusion of such content within normal parsed character data would be likely result in well-formedness or validity errors. This can be done with a CDATA section inserted in your document instance. If you wanted such a fragment to appear within the <example> element of the DTD you would do the following:

    <example>
      <![CDATA[
       <poem>
         <title>The Raven</title>
         <author>Edgar Allen Poe</>
       <poem>
      ]]>
     <example>
    

There are numerous examples of this in the two samples discussed in the previous section. Chapter 2 of XML in a Nutshell also discusses this technique.

Generating XHTML from a DTM Instance using XSL

A DTM stylesheet exists that will generate valid XHTML if applied to a DTM instance. However browser support for client-side XSL is wildy inconsistent. I've discovered only 1 browser, IE 6.0, which will reliably apply and process an XSL stylesheet at the time an XML document instance associated with one loads, so I'll follow with directions for using both client-side XSLT and how to use a command line utility to conduct an XSLT transformation of a DTM instance.

Client-Side XSL Processing

All you need to do to set up client-side XSL processing is to insert a processing instruction at the beginning of your document instance. This directs your browser to the location of the stylesheet and tells it to conduct an XSL transformation upon loaded your page. You would write:


   <?xml version="1.0" encoding="UTF-8"?>
   <?xml-stylesheet type="text/xsl" 
     href="http://classrm06.lis.uiuc.edu/~kmreiss/projects/dtdmodel/model.xsl"?>
   <!DOCTYPE model SYSTEM 
     "http://www.isrl.uiuc.edu/~kmreiss/dtdmodel/model.dtd">
 
  

Command-Line XSL

Client-side XSL being what it is, it is best to generate a static XHTML version of the documentation that all browsers can be reliably counted on to display. you'll have to generate an XHTML version of the document instance using a command line at the UNIX prompt. A short program doctypemodel will call an XSLT processor and generate an XHTML version of your DTM. This program uses libxslt, so you'll need to install libxslt or edit the program to call your command-line XSLT processor of choice.

To run this program all you need to do is have the location of doctypemodel on your path and be in the same working directory as your DTM instance file. If your document instance is called poemdoc.xml just type the following at the command prompt.

    classrm01:~/public_html/demos/dtdmodel 515 $ doctypemodel poemdoc
  

You should now have a file called poemdoc.html in the directory where you ran the above command at.

    classrm01:~/public_html/demos/dtdmodel 515 $ ls  
    -rwxr-xr-x    1 LIS450DP LIS450DP    56576 Apr  8 22:35 poemdoc.html
    -rwxr-xr-x    1 LIS450DP LIS450DP    47969 Apr  8 22:33 poemdoc.xml

   

Example DTM Files

model.dtd DTD File
model.xsl XSL Stylesheet
modeldoc.xml DTM for a DTM
modeldoc.html XHTML version of modeldoc.xml
poemdoc.xml DTM for the example poem document type.
poem.dtd DTD for the example poem document type
sue.xml example document instance of poem DTD
poemdoc.html XHTML version of poemdoc.xml
model.css CSS Stylesheet for XHTML versions of DTMs generated with model.xsl
doctypemodel Perl script to call command-line XSLT Processor
model.zip Zip file containing all of the above

References

  1. Eve Maler and Jeanne El Andaloussi. Developing SGML DTDs: From Text to Model to Markup published by Prentice-Hall PTR (1996, ISBN: 0-13-309881-8)
  2. Elliotte Rusty Harold and W. Scott Means. XML in a Nutshell: 2nd Edition published by O'Reilly & Associates (2002, ISBN: 0-596-00292-0)

Last Update: 7/27/03