Archive for May, 2009

XML Basics: DTD & Its Uses

What is a DTD? What is it used for?

The document type definition (DTD) defines the valid syntax of a class of XML documents. That is, it lists a number of element names, which elements can appear in combination with which other ones, what attributes are available for each element type, etc. A DTD uses a different syntax from that used by XML documents.

Do Web developers have to include a DTD when they use XML to describe data?

No! XML can be used to describe data with or without a DTD. The term “valid” XML refers to XML data that references a DTD, while “well-formed” XML refers to XML that does not use a DTD. The addition of well-formed XML is one of the fundamental differences between XML and SGML.

Clearly, in both cases, the XML itself must conform to the standards for the language (so, for example, all tags must be closed and tags may not overlap).