DOCTYPE Declaration

  • Definition:

    The XML document type declaration contains or points to markup declarations that provide a grammar for a class of documents. This grammar is known as a document type definition, or DTD. The document type declaration can point to an external subset (a special kind of external entity) containing markup declarations, or can contain the markup declarations directly in an internal subset, or can do both. The DTD for a document consists of both subsets taken together.

  • Notation:

    <!DOCTYPE greeting SYSTEM "hello.dtd">
    <!DOCTYPE greeting PUBLIC "Public Identifier" "hello.dtd">
    <!DOCTYPE test [
      <!ELEMENT test (#PCDATA)>
    ]>
    					
  • System Identifier

    The system identifier "hello.dtd" gives the address (a URI reference) of a DTD for the document.

  • Public Identifier

    An XML processor attempting to retrieve the entity's content MAY use any combination of the public and system identifiers as well as additional information outside the scope of this specification to try to generate an alternative URI reference.

  • Internal Subset

    Allows to contain Markup Declarations in the XML Document.

  • Avoid Usage:

    They are a legacy from SGML, make documents less standalone and transparent especially considering the definition of default attribute values.