This is an old revision of the document!
DTD (Document Type Definition)
In simple cases, DTD is used to describe the syntax of a data structure stored in XML. This DTD can be saved in a file with a .dtd
extension, but it can also be part of the XML document itself.
Basic Properties of DTD
- Allows for simple syntactic validation.
- A descriptive language similar to extended Backus-Naur form.
- You can define structures, required sequences, type constraints, and cardinality.
If an XML document has a document type declaration, it must be indicated in the file with a special declaration starting with `<!DOCTYPE>`. The type declaration can be internal or external (referenced via URI or a file).
Internal declaration
<!DOCTYPE uzenet [ .... ]>
External URI
<!DOCTYPE html PUBLIC "-//W3//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/......dtd">
External file
<!DOCTYPE uzenet SYSTEM "filename.dtd">
The DTD defines the structure and rules that an XML document must follow to be considered valid.