Document Type Definition - Associating DTDs With Documents

Associating DTDs With Documents

A DTD is associated with an XML or SGML document by means of a Document Type Declaration. The Document Type Declaration appears in the syntactic fragment doctypedecl near the start of an XML document. The declaration establishes that the document is an instance of the type defined by the referenced DTD.

DTDs make two sorts of declaration:

  • an optional external subset
  • an optional internal subset

The declarations in the internal subset form part of the Document Type Declaration in the document itself. The declarations in the external subset are located in a separate text file. The external subset may be referenced via a public identifier and/or a system identifier. Programs for reading documents may not be required to read the external subset.

Note that any valid SGML or XML document that references an external subset in its DTD, or whose body contains references to parsed external entities declared in its DTD (including those declared within its internal subset), may only be partially parsed but cannot be fully validated by validating SGML or XML parsers in their standalone mode (this means that these validating parsers will not attempt to retrieve these external entities, and their replacement text will not be accessible).

However, such documents will still be fully parsable in the non-standalone mode of validating parsers, which will signal an error if these external entities cannot be located with their specified public identifier (FPI) and/or system identifier (a URI), or are inaccessible. (Notations declared in the DTD are also referencing external entities, but these unparsed entities are not needed for the validation of documents in the standalone mode of these parsers: the validation of all external entities referenced by notations is left to the application using the SGML or XML parser). Non-validating parsers may eventually attempt to locate these external entities in the non-standalone mode (by partially interpreting the DTD only to resolve their declared parsable entities), but will not validate the content model of these documents.

Read more about this topic:  Document Type Definition

Famous quotes containing the word documents:

    The American Constitution, one of the few modern political documents drawn up by men who were forced by the sternest circumstances to think out what they really had to face instead of chopping logic in a university classroom.
    George Bernard Shaw (1856–1950)