Document Type Definitions (DTD)


  1. DTDs are a set of rules that define how XML data should be structured.
  2. Cooperating applications can share a single description of data known as XML vocabulary. A group of XML documents that share common XML vocabulary is known as document type and each individual document that conforms to a document type is a document instance.
  3. Multiple documents and applications can share DTDs
  4. Validity constraints ensure that any XML data conforms to its associated DTD.
  5. Only one DTD may be associated with a given XML document or data object.
  6. DTD has 2 parts – internal subset, external subset. DTD declarations in internal subset have priority over those in external subset.
  7. An XML document can be associated with only one DTD using a single DOCTYPE declaration.
  8. Syntax of DOCTYPE declaration:
    1. <!DOCTYPE doc_element SYSTEM location [internal_subset]>
    2. <!DOCTYPE doc_element PUBLIC identifier location [internal_subset]>
  9. Only comments and PIs cam be inserted between XML declaration and DOCTYPE declaration.
  10. DTDs are associated with the entire element tree via the document element.
  11. “#” character as URI fragment identifier cannot be used in the location of a DTD.
  12. The use of PUBLIC identifier should be limited to internal systems and legacy SGML applications.
  13. Four basic keywords used in DTD declaration are:
    1. ELEMENT
    2. ATTLIST
    4. ENTITY
  14. ELEMENT:
    Syntax: <!ELEMENT ele_name content_category> <!ELEMENT ele_name (content_model)cardinality)>

    Content_category : ANY or EMPTY

  15. Content_Model : Text only, Element only, Mixed
  16. Child elements in mixed content can appear (or not) in any order, any number of times.
  17. Syntax of mixed content:
    1. No fixed sequence
    2. #PCDATA must be the first item
    3. “*” operator is needed as the mixed content doesn’t constain the no. of occurrences of the child elements.
  18. ATTLIST declaration Syntax:
  19. Attribute defaults: #REQUIRED, #IMPLIED, #FIXED, Default values
  20. Attribute types: (10 in number)
    1. CDATA
    2. Enumeration
    3. ID
    4. IDERF
    5. IDERFS
    6. NMTOKEN
    9. ENTITY
    10. ENTITIES
  21. Order of attributes cannot be enforced
  22. ID attribute type must not be used with #FIXED
  23. ID value must be unique within a given document
  24. Only one ID attribute for each element type
  25. NMTOKEN attribute prevents the inclusion of whitespace and some punctuation characters
  26. NOTATION can be used to identify
    1. The format of unparsed entities
    2. The format of element attributes of ENTITY and ENTITIES type
    3. The application associated with a PI
  27. Entities can be used to include a document inside a DTD
  28. If an element is declared more than once, its an error
  29. If an entity is declared more than once, only the first declaration is binding, other declarations are ignored.


Like it? Please Spread the word!

Post Your Thoughts