Apr 26, 2008

DTD Keywords

DTD Keywords

Document Type Definition (DTD) ELEMENT Keyword

The ELEMENT keyword defines elements that may be a part of the document and their options or requirements. Each element may or may not require the use of other elements within it. There are three parts of the element definition which include:

  1. Name - The element name.
  2. Specification of beginning and ending tags
  3. Element content.

Ending tag Specifications

This part specifies whether beginning or ending tags are required. The following list explains the possibilities.

  • - - Start and end tags mandatory.
  • - O Omit the end tag if desired.
  • O O Omit the start and end tag if desired.

ELEMENT Content

Content specifies the content of the elements. This uses the word "EMPTY" and special characters combined with names to define content.

EMPTY

The word "EMPTY" designates the element has no content. Here's an example from the HTML 4 transitional DTD:

<!ELEMENT HR - O EMPTY -- horizontal rule -->

Characters

Character meanings:

  • ? - The element may appear once but does not need to appear at all (optional).
  • + - The element must appear one or more times (repeatable and required).
  • - - (One minus sign) The element must not appear.
  • * - The element does not need to appear, but may appear multiple times (optional and repeatable).
  • , - The elements must appear in the order listed (sequential).
  • | - Any one or more of the elements included in the group must exist.
  • & - All the elements included in the group must appear in any order.

() - These brackets are placed around a group of elements to set them apart from other elements. You will see many examples of this.

Examples

In the examples below, the names "ENT1", "ENT2", and so forth are used to describe elements:

  • ENT1? - The element "ENT1" may appear once, but may not appear at all. (<=1)

<!ELEMENT FRAMESET - - ((FRAMESET|FRAME)+ & NOFRAMES?) -- window subdivision-->

  • ENT1 - The element "ENT1" must apear once only. (1)
  • ENT1+ - The element "ENT1" must appear one or more times. (>=1)

<!ELEMENT TBODY O O (TR)+ -- table body -->

  • -(ENT1) The element must not appear.
·         <!ENTITY % pre.exclusion "IMG|OBJECT|APPLET|BIG|SMALL|SUB|SUP|FONT|BASEFONT">
·         <!ELEMENT PRE - - (%inline;)* -(%pre.exclusion;) -- preformatted text -->
  • ENT1* - The element "ENT1" may appear one or more times, but may not appear at all. (>=0)
  • ENT1 | ENT2 - Any of the Elements ENT1 or ENT2 may appear one or more times.

<!ENTITY % head.misc "SCRIPT|STYLE|META|LINK|OBJECT" -- repeatable head elements -->

  • ENT1, ENT2 - The elements "ENT1" and "ENT2" must occur in order. In the below example, if a CAPTION appears, it must appear first, then 0 or more occurrances of COL or COLGROUP may appear, then a THEAD may appear and so forth.

<!ELEMENT TABLE - - (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>

  • ENT1 & ENT2 - The elements "ENT1" and "ENT2" must occur, but may appear in any order.
  • (ENT1|ENT2)+ - Of the elements ENT1 or ENT2, there must be one or more occurances of one of them.

<!ELEMENT TR - O (TH|TD)+ -- table row -->
<!ELEMENT DL - - (DT|DD)+ -- definition list -->

No comments:

Post a Comment

Popular Posts