XML

The Default Declaration

The default declaration can consist of any valid value for your attributes, or it can consist of one of three predefined keywords: #REQUIRED, #IMPLIED, or #FIXED. The #REQUIRED keyword indicates that the attribute must be included with the element and that it must be assigned a value. There are no default values when #REQUIRED is used. The #IMPLIED keyword indicates that the attribute does not have to be included with the element and that there is no default value. The #FIXED keyword sets the attribute to one default value that cannot be changed. The default value is listed after the #FIXED keyword. If none of these three keywords are used, a default value can be assigned if an attribute is not set in the XML document.

The Revised DTD

Based on this information about the components of the !ELEMENT and !ATTLIST statements, we can rewrite our original DTD as follows:

  <!ELEMENT html  (head, body)>
  <!ELEMENT head  (title, base?)>
  <!ELEMENT title  (#PCDATA)>
  <!ELEMENT base EMPTY>
  <!ATTLIST base  target CDATA  #REQUIRED>
  <!ELEMENT body  (basefont?, a?, table)>
  <!ATTLIST body  alink   CDATA  #IMPLIED
                  text    CDATA  #IMPLIED
                  bgcolor CDATA  #IMPLIED
                  link    CDATA  #IMPLIED
                  vlink   CDATA  #IMPLIED>
  <!ELEMENT basefont EMPTY>
  <!ATTLIST basefont  size CDATA  #REQUIRED>
  <!ELEMENT a  (#PCDATA)>
  <!ATTLIST a  linkid ID     #IMPLIED
               href   CDATA  #IMPLIED
               name   CDATA  #IMPLIED
               target CDATA  #IMPLIED>
  <!ELEMENT table  (tr+)>
  <!ATTLIST table  width       CDATA  #IMPLIED
                   rules       CDATA  #IMPLIED
                   frame       CDATA  #IMPLIED
                   align       CDATA  'Center'
                   cellpadding CDATA  '0'
                   border      CDATA  '0'
                   cellspacing CDATA  '0'>
  <!ELEMENT tr  (td+)>
  <!ATTLIST tr  bgcolor  (Cyan | Lime | Black | White | Maroon)  'White'
                valign   (Top | Middle | Bottom)  'Middle'
                align    (Left | Right | Center)  'Center'>
  <!ELEMENT td  (CellContent)>
  <!ATTLIST td  bgcolor  (Cyan | Lime | Black | White | Maroon)  'White'
                valign   (Top | Middle | Bottom)  'Middle'
                align    (Left | Right | Center)  'Center'
                rowspan CDATA  #IMPLIED
                colspan CDATA  #IMPLIED>
  <!ELEMENT CellContent  (h1?| p?)+>
  <!ATTLIST CellContent  cellname CDATA  #REQUIRED>
  <!ELEMENT h1  (#PCDATA)>
  <!ATTLIST h1  align CDATA  #IMPLIED>
  <!ELEMENT ImageLink  (img, br?)>
  <!ELEMENT p  (#PCDATA | font | ImageLink | a | ul | ol)+>
  <!ATTLIST p  align CDATA  #IMPLIED>
  <!ELEMENT font  (#PCDATA | b)*>
  <!ATTLIST font  color  (Cyan | Lime | Black | White | Maroon)  'Black'
                  face   (&apos;Times New Roman &apos;| Arial) #REQUIRED
                  size   (2 | 3 | 4 | 5 | 6)  '3'>
  <!ELEMENT b  (#PCDATA)>
  <!ELEMENT img EMPTY>
  <!ATTLIST img  width  CDATA  #IMPLIED
                 height CDATA  #IMPLIED
                 hspace CDATA  #IMPLIED
                 vspace CDATA  #IMPLIED
                 src    CDATA  #IMPLIED
                 alt    CDATA  #IMPLIED
                 align  CDATA  #IMPLIED
                 border CDATA  #IMPLIED
                 lowsrc CDATA  #IMPLIED>
  <!ELEMENT br EMPTY>
  <!ATTLIST br  clear CDATA  #REQUIRED>
  <!ELEMENT ul  (font?, li+)>
  <!ATTLIST ul  type CDATA  #IMPLIED>
  <!ELEMENT li  (font?| a?)+>
  <!ELEMENT ol  (font?, li+)>
  <!ATTLIST ol  type  CDATA  #REQUIRED
                start CDATA  #REQUIRED>

The body element contains two optional child elements, basefont and a, and one required element, table. For this example, because you are using a table to format the page and all information will go into the table, the table element is required. The a element is used to create an anchor to the top of the page, and the basefont element specifies the default font size for the text in the document. Because all of the attributes associated with the body element are optional, they include the keyword #IMPLIED.

In the base element, the target attribute is required. It would make no sense to include a base element without specifying the target attribute, as the specification of this attribute is the reason you would use the base element. Therefore, the target attribute is #REQUIRED.

In the font element, the color and size attributes have enumerated data types and are assigned default values (Black and 3). The face attribute remains unchanged.