A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines rules for a specific type of document, including:
To apply a DTD to an XML document, you can:
An XML Schema describes the structure of an XML instance document by defining what each element must or may contain.XML Schema is expressed in the form of a separate XML file.
|Schema document is an XML document i.e., the structure of an XML document is specified by another XML document.||DTDs follow SGML syntax.|
|Schema supports variety of dataTypes similar to programming language.||In DTD everything is treated as text.|
|In Schema, It is possible to inherit and create relationship among elements.||This is not possible in DTD without invalidating existing documents.|
|In Schema, It is possible to group elements and attributes so that they can be treated as single logical unit.||Grouping of elements and attributes is not possible in DTD.|
|In Schemas, it is possible to specify an upper limit for the number of occurrences of an element||It is not possible to specify an upper limit of an element in DTDs|
A complex element is an XML element that contains other elements and/or attributes.
There are four kinds of complex elements:
A simple element is an XML element that can contain only text.