XML DTD reference

Author: Razvan MIHAIU
razvan_rem@rem_mihaiu.name (please remove '_rem' and 'rem_')
From: www.mihaiu.name
Date: 20/06/2005
  1. <!ELEMENT>
  2. <!ENTITY>
  3. <!ATTLIST>

    -defines the attributes of an XML element (permissible and default values);

    Attribute definitions:

    Attribute types: (there are 10 types)

    1. CDATA - in CDATA you cannot have external entities, nor contain unescaped "<" signs; the less-than sign must be encoded "<"; for an example of CDATA attribute see above;
    2. Enumerated values - all the enumerated values must be composed of NameChars; for an example see above;
    3. ID - a unique identifier in the whole document instance (regardless of the element type):
      <!ATTLIST Test6 an_attribute ID #IMPLIED> <!ATTLIST Test6 an_attribute ID #REQUIRED>
    4. IDREF/IDREFS - the value of such an attribute must be a legal XML name and must match an ID in the same document instance:
      <!ATTLIST Test5 ID ID #IMPLIED Ref IDREFS #REQUIRED Ref2 IDREF #IMPLIED > <!ELEMENT Test5 EMPTY> <!-- this element has an optional ID, a required IDREFS and an optional IDREF; the IDREFS attribute has a single value that points to the same element --> <Test5 ID="abc" Ref="abc"/>
    5. NMTOKEN/NMTOKENS

      - the only real difference between NMTOKEN and CDATA is that the former will not allow the whitespace and some punctuation characters;

      - NMTOKEN/NMTOKENS only allow NameChar characters;

      <!ATTLIST Test5 Year NMTOKEN #IMPLIED Values NMTOKENS #REQUIRED TimeStamp NMTOKEN #FIXED "15:00" Parts NMTOKENS "A37 B100 C90" >
    6. ENTITY/ENTITIES

      - the values of such attributes must match the names of *unparsed* entity already declared in the DTD;

      <!-- DTD --> <!ELEMENT Test5 EMPTY> <!ATTLIST Test5 Img1 ENTITY #REQUIRED Img2 ENTITY #FIXED "Toto1" Img3 ENTITY #IMPLIED Img4 ENTITY "def" > <!ENTITY Toto1 PUBLIC "id" "loc" NDATA NotNo500> <!NOTATION NotNo500 PUBLIC "ident" "loc"> <!-- XML --> <Test5 Img1="Toto11"/>
    7. NOTATION

      - must point to a notation that is explicitely defined in the DTD;

  4. <!NOTATION>

    - this tag is used to describe non-xml data; its a hint to the application about handling unparsable data;

    <!NOTATION name SYSTEM "location"> <!NOTATION name PUBLIC "identifier" "location">
  5. conditional sections: IGNORE & INCLUDE directives;
    <![INCLUDE [ <!ELEMENT Test7 EMPTY> ]]> <![IGNORE [ <!ELEMENT Test8 EMPTY> ]]>

    - parameter entities must be used in order to achieve the effect of conditional sections:

    <!ENTITY % TestCondition "INCLUDE"> <![%TestCondition; [ <!ELEMENT Test9 EMPTY> ]]>

If you wish to add something feel free to use the forums.







Best regards,
Razvan MIHAIU



Razvan Mihaiu © 2000 - 2009