DTD versus XML Schema

 

DTD versus XML Schema

Both DTD and XML Schema are used to structure data and validate the XML syntax.

In the future, XML Schema might be used as a replacement for DTD's because of the following reasons (according to the W3Schools XML Schema Tutorial) :

XML Schemas...

    ...are extensible to future additions,
    ...are richer and more useful than DTDs,
    ...are written in XML,
    ...support simple (integer, decimal, string, boolean, dateTime, etc.) and complex data types ,
    ...support namespaces.

Because XML Schemas are written in XML they possess the same advantages as XML documents (listed in chapter Introduction to XML).

XML Schema provides more precise control over the text content of elements and attributes and their occurance than DTDs:

    Element occurance constraints
    Maximum and minimum number of times an element can occur (minOccurs, maxOccurs)
    Simple (integer, decimal, string, boolean, dateTime, etc.) and complex data types

    Simple Data Type in a XML SchemaSimple Data Type in a XML Schema
    Complex Data Type in a XML SchemaComplex Data Type in a XML Schema
    Explicit restrictions on the sequence of child elements.
    There are three possibilities how to control the order of the child elements:
        <xs: all>: specifies that the child elements can appear in any order and that each child element must occur once and only once.
        <xs: choice>: specifies that either one child element or another can occur.
        <xs: sequence>: specifies that the child elements must appear in a specific order.
    Specific rules about the contents of elements and attributes

If you are interested in a list with the possible content restrictions for the content of elements and attributes, have a look at this popup-part (Click here for more information)

However, DTDs do not provide fine control over the format and data types of element and attribute values. Once an element or attribute has been declared to contain character data, no limits may be placed on the length, type, or format of that content. (Harold et al. 2002)

http://www.e-cartouche.ch/content_reg/cartouche/datastruc/en/html/dtd_schema_learningObject4.html