documents

Custom Document Type Definitions

A Document Type Definition (DTD)

A DTD is a generic document which describes the content of another document (here a HTML or XHTML document). In other words, it defines the elements and attributes which make up the markup that a browser will interpret to display and layout the document, and how they interact.

Document validation

What is validation? Validation is a process through which the conformity of a document is checked against its description (DTD). Reasons to validate a document include:

Some organizations provide tools for validating different types of documents, such as HTML, XHTML, style sheets (CSS) or other documents. Two organizations are standing out of the crowd because of their importance or quality of service regarding validation.

The first is the World Wide Web Consortium (W3C)[1], official keeper of standards (Recommendations) used on the Internet. All validation services are referring to these standards. The W3C provides different online validation tools in relation to their different published standards. We are interested in the following tool:

The second is the Web Design Group (WDG)[2] which validator, in addition to services similar to those of W3C validator, allows validation of documents with a custom DTD. This is the tool:

Why use a custom DTD?

Some browsers are still using proprietary tags or attributes, and we sometimes have to use non-standard elements or attributes for compatibility reasons. Here are two examples:

Too many pages are failing validation tests essentially because validators can only check them against the standard DTDs. Systematically, they stumble on pages containing elements or attributes which are not part of these standard DTDs. Validation results can also be intimidating or discouraging to authors. To ease code correction and promote better coding practices, one must be pragmatic sometimes.

How to customize a DTD?

Warning

As of June 2007: The situation that prevailed when this page was published in 2001 has changed. Customizing a DTD could be justified then by mere presence of legacy browsers. But they have been relentlessly pushed to oblivion by newer browsers (supposed to implement recent standards).

Today other solutions[3] allow validation of documents containing QuickTime or Flash movies without altering W3C standard DTDs. Note also that use of a custom DTD may impact page interpretations by browsers[4].

This option is thus not recommanded anymore for HTML documents. However, the following guide is still valid.

By altering W3C standard DTDs. For HTML 4.01[5], from the loose.dtd and/or frameset.dtd documents, and for XHTML 1.0[6], from xhtml1-transitional.dtd or xhtml1-frameset.dtd documents.

For example, in HTML 4.01, here is how to modify:

And similarly in XHTML 1.0:

Declaring a custom DTD

A DTD is associated to a documents through a document type declaration DOCTYPE at the beginning of HTML or XHTML documents.

For example, the following HTML document has a standard DTD:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">

Let say that this document is hosted on example.net ; a custom DTD will be associated like this:

<!DOCTYPE HTML SYSTEM "http://example.net/loose_custom.dtd">

We substitute the PUBLIC identifier from the standard definition with a SYSTEM identifier, then we specify the location (URL) of the modified DTD in the website.

(Same principle for a XHTML document except that we'll have to write html in lowercase as XHTML is case sensitive.)

Then there are two cases:

The World Design Group Validator

A rarity in the world of validators, the WDG Validator is able to process HTML or XHTML documents with a custom DTD.

XML: A Special Case

If you need to validate a XHTML document with a custom DTD, the validator has a limitation by which the XML nature of the document must be explicitly declared. This can be done in two ways:

This option is only available in validation by URL mode.

Validation examples

Two examples of validation with custom DTD are provided: one with HTML documents and one with XHTML documents. Different custom DTDs are used simultaneously, and both examples are sharing the same template: a frameset defining an upper frame for navigation and a lower frame for main display.

<frameset rows="40%,*" border="0" frameborder="0" framespacing="0">
    <frame name="navigation" src="navigation.php"
        title="Navigation frame"
        marginheight="0" marginwidth="0" frameborder="0">
    <frame name="principal" src="principal.php"
        title="Main display frame"
        marginheight="0" marginwidth="0" frameborder="0">
</frameset>

Example template (frameset.php)

The frameset definition page is associated to a custom DTD (non-standard attributes appear bolder in above code) ; the navigation frame references a document named navigation.php associated to a W3C standard DTD ; the principal frame references a document named principal.php which includes a QuickTime animation and which is associated to a custom DTD.

Download

Custom DTDs given as examples are available in the following compression formats. Once decompressed, open files with a text editor and follow instructions inside for adaptating these DTDs to your needs:

References

  1. W3C website
  2. WDG website
  3. An article entitled Flash Satay published on alistapart.com indicating how to include a Flash movie using only a standard element object. See also a more exhaustive article on this subject published on Devedge.

    Additionally, following the Eolas patent case in 2003, named from the patent holding company, all editors worried at the idea of commiting any patent infringement recommand to use dynamic solutions based on scripts. For example, see instructions provided by Apple®, Adobe® and Real Networks® for embedding, respectively, QuickTime™, Flash™ and RealVideo™ movies

  4. An article entitled Quirks mode and strict mode published on quirksmode.org
  5. HTML 4.01 Recommendation and related DTDs loose.dtd and frameset.dtd
  6. XHTML 1.0 Recommendation and related DTDs xhtml1-transitional.dtd and xhtml1-frameset.dtd
  7. WDG pages about DTD customization and difference between a validator and a linter
  8. Everything about the embed tag (Netscape®)
  9. How to include a QuickTime movie (Apple®)
  10. How to include a Flash movie (Adobe®)
  11. The WDG Validator hidden option for XHTML documents (XML) with custom DTD.
© 1999-2008 yoyodesign.org — Some rights reserved