DTD Example Explanation
The example DTD on the previous page is listed again below with explanations where appropriate. The line numbers are not part of the DTD but are provided for reference. Lines 1 through 15 are used to define entities which are used for element declarations. The establishment of these entities makes the text much shorter and easier to use since entities can be used to establish and group both standard elements and common attributes. On lines 17 and 18, below, the entity is used to declare a complete group of elements at one time thus saving a great deal of space and effort. Entities may be contained in external files, but the use of external entities is not shown here.
- <!ENTITY % HTML.Version "-//W3C//DTD HTML 4.01 Transitional//EN">
- <!ENTITY % Script "CDATA" -- script expression -->
- <!ENTITY % URI "CDATA" -- a Uniform Resource Identifier, see [URI] -->
- <!ENTITY % StyleSheet "CDATA" -- style sheet data -->
- <!ENTITY % heading "H1|H2|H3|H4|H5|H6">
- <!ENTITY % list "UL | OL">
- <!ENTITY % coreattrs
"id ID #IMPLIED -- document-wide unique id --
class CDATA #IMPLIED -- space-separated list of classes --
style %StyleSheet; #IMPLIED -- associated style info --
title %Text; #IMPLIED -- advisory title --"
>
- <!ENTITY % events
"onclick %Script; #IMPLIED -- a pointer button was clicked --
ondblclick %Script; #IMPLIED -- a pointer button was double clicked--
onmousedown %Script; #IMPLIED -- a pointer button was pressed down --
onmouseup %Script; #IMPLIED -- a pointer button was released --
onmouseover %Script; #IMPLIED -- a pointer was moved onto --
onmousemove %Script; #IMPLIED -- a pointer was moved within --
onmouseout %Script; #IMPLIED -- a pointer was moved away --
onkeypress %Script; #IMPLIED -- a key was pressed and released --
onkeydown %Script; #IMPLIED -- a key was pressed down --
onkeyup %Script; #IMPLIED -- a key was released --"
>
- <!ENTITY % attrs "%coreattrs; %events;">
- <!ENTITY % align "align (left|center|right|justify) #IMPLIED">
- <ENTITY % phrase
"EM | STRONG | DFN | CODE | SAMP
| KBD | VAR | CITE | ABBR | ACRONYM" >
- <!ENTITY % fontstyle
"TT | I | B | U | S | STRIKE | BIG | SMALL">
- <!ENTITY % inline
"#PCDATA | %phrase; | %fontstyle;">
- <ENTITY % block
"P | %heading; | %list; | HR">
- <!ENTITY % flow "%block; | %inline;">
- <ELEMENT BODY O O (%flow;)* -- document body -->
<ATTLIST BODY %attrs; -- %coreattrs, %i18n, %events --
onload %Script; #IMPLIED -- the document has been loaded --
onunload %Script; #IMPLIED -- the document has been removed --
background %URI; #IMPLIED -- texture tile for document background --
>
- <!ELEMENT (%fontstyle; | %phrase;) - - (%inline;)*>
<!ATTLIST (%fontstyle; | %phrase;)
%attrs; -- %coreattrs, %events --
>
- <!ELEMENT (%heading;) - - (%inline;)* -- heading -->
>!ATTLIST (%heading;)
%attrs; -- %coreattrs, %i18n, %events --
%align; -- align, text alignment -- >
- <!ENTITY % Length "CDATA" -- nn for pixels or nn% for percentage length -->
- <!ENTITY % Pixels "CDATA" -- integer representing length in pixels -->
- <!ELEMENT HR - O EMPTY -- horizontal rule -->
<!ATTLIST HR
%attrs; -- %coreattrs, %i18n, %events --
align (left|center|right) #IMPLIED
noshade (noshade) #IMPLIED
size %Pixels; #IMPLIED
width %Length; #IMPLIED
>
- <!ELEMENT P - O (%inline;)* -- paragraph -->
<!ATTLIST P
%attrs; -- %coreattrs, %i18n, %events --
%align; -- align, text alignment --
>
- <!ENTITY % OLStyle "CDATA" -- constrained to: "(1|a|A|i|I)" -->
- <!ELEMENT OL - - (LI)+ -- ordered list -->
<!ATTLIST OL
%attrs; -- %coreattrs, %i18n, %events --
type %OLStyle; #IMPLIED -- numbering style --
compact (compact) #IMPLIED -- reduced interitem spacing --
start NUMBER #IMPLIED -- starting sequence number --
>
- <!ENTITY % ULStyle "(disc|square|circle)">
<!ELEMENT UL - - (LI)+ -- unordered list -->
<!ATTLIST UL
%attrs; -- %coreattrs, %i18n, %events --
type %ULStyle; #IMPLIED -- bullet style -- compact
(compact) #IMPLIED -- reduced interitem spacing -- >
- <!ENTITY % LIStyle "CDATA" -- constrained to: "(%ULStyle;|%OLStyle;)" -->
- <!ELEMENT LI - O (%flow;)* -- list item -->
<!ATTLIST LI
%attrs; -- %coreattrs, %i18n, %events --
type %LIStyle; #IMPLIED -- list item style --
value NUMBER #IMPLIED -- reset sequence number --
>
- <!ENTITY % version "version CDATA #FIXED '%HTML.Version;'">
- <!ENTITY % html.content "HEAD, BODY">
- <!ELEMENT HTML O O (%html.content;) -- document root element -->
<!ATTLIST HTML
%version; >
|
|