XML Schema vs. DTD

Difference Between XML Schema and DTD

XML means Extensible markup language. The XML 1.0 specification developed by W3C (World Wide Web Consortium), gives its definition, which is developed by the. XML provides a simple and standard way which encodes data as text content can be exchanged through the hardware drivers, operating systems and applications with little human intervention. The XML Schema describes the structure of an XML document. The XML Schema puts constraints on the structure and content of an XML document with syntax rules to be followed in XML. The XML Schema is a recommendation provided by the Web Consortium (W3C) and it became a recommendation in May 2001. DTD (the Document Type Definition) also tells how the document elements are ordered and nested, what items are included in the document and the attributes of contents. In SGML markup language the structure of document is defined by DTD.

What is XML Schema?

The XML Schema shows about the structure of an XML document. It tells about the elements that can appear in an XML document and their attributes as if an element is empty or can contain text. It also defines that the elements are child elements and the order of the elements of a child. In addition, the XML schema tells about the data types used in elements and its attributes. XML schemas are mostly used by web applications because it is scalable and provides support for namespaces and data types. The greatest strength with the XML Schema provides support for data types. It provides easy ways to define the content allowed in a document and methods to ensure the accuracy of data. In addition, the XML Schema has previous preparation for working with data in the database and allows the conversion between data types.

What is DTD?

DTD defines the structure of documents in the languages ​​of SGML markup languages such as SGML, HTML and XML. It defines how the elements of documents are ordered and nested, what items are included in the documents and the attributes of contents. In an XML document, DTD is declared in a DOCTYPE declaration, which is below the XML declaration. The body of the DTD is the definition for the elements in the document and their attributes and can be defined as an inline definition or an external definition. Possession of external DTD is very useful when using the XML protocol for communicating between the separate systems as it reduces the air to return the DTD each time as the inline definition. External DTD could be placed in a place like a web server which could be accessed by both systems.

What is the difference between XML Schema and DTD?

DTD precedes XML Schema. The DTD gives the structure / grammar fundamental to define an XML document, in addition to the XML schema which provides methods to define the constraints of the data contained in the document. So we consider that the XML Schema is powerful and richer than DTD. Also, the XML Schema provides an object-oriented approach to define the structure of an XML document. But since the XML Schema is latest technology, yet some of XML parsers did not support it. Furthermore, most definitions of rich and complex legacy systems are defined with DTDs. To rewrite same is not an easy task.


Category: VS  |  Tags: