Compare the Difference Between Similar Terms

Difference Between

Home / Technology / IT / Database / Difference Between DTD and XSD

Difference Between DTD and XSD

March 22, 2018 Posted by Lithmee

Key Difference – DTD vs XSD
 

DTD and XSD are related to XML, which is used for data transfer among its several functions. Most applications require data transfer. When the client machine requires getting data from the server, there should be an effective method to fetch data. XML can be used to achieve this task. It stands for Extensible Markup Language. The main advantage of using XML is to transfer data. Other than that, it can also be used to configure frameworks and for designing the layout for android applications. The tags used in XML are not predefined. The programmer can write the tags according to the application. An XML document contains the structure and the content. In XML, the DTD stands for Document Type Definition and XSD stands for XML Schema Definition. DTD is a set of markup declarations that define a document type for an SGML – family markup language. XSD specifies how to describe the elements in an Extensible Markup Language document formally. The key difference between DTD and XSD is that DTD can be used to define the structure while XSD can be used to define the structure and content.  This article discusses the difference between DTD and XSD.

CONTENTS

1. Overview and Key Difference
2. What is DTD
3. What is XSD
4. Similarities Between DTD and XSD
5. Side by Side Comparison – DTD vs XSD in Tabular Form
6. Summary

What is DTD?

DTD stands for Document Type Definition. It is used to describe XML language precisely. The main objective of DTD is to define the structure of an XML file. It contains a list of legal elements. It is also used to perform validation. There are two types of DTD. They are internal or external. If the DTD elements are declared within the XML file, it is known as internal DTD. If the DTD elements are declared in some other file, it is known as external DTD.

Difference Between DTD and XSD

Figure 01: Internal DTD

According to the above, the elements are declared within the XML file. So, it is an internal DTD. The <! DOCTYPE Student defines that the root element of the document is Student. The <! Element Student (ID, Name, Email) > defines that the Student element consists of three elements that are ID, Name and Email. Each ID, Name and Email are defined separately. They all are parse-able data types. DTD exist from line number 2 to 7. The rest is XML.

Difference Between DTD and XSD_Figure 02

Figure 02: Adding the external DTD file

When the DTD file is saved as student.dtd, it should be added to the XML file. It is done as follows;

<! DOCTYPE Student SYSTEM “student.dtd”>

What is XSD?

XSD stands for XML Schema Definition. It is used to define the structure and the content of XML files. It is a method of expressing constraint of the XML file. XSD is similar to DTD, but it is providing more control on XML structure. There are two types of XSD files. They are simple Type and complex Type. The simpleType allows having text-based elements. It contains fewer attributes, child elements and cannot be left empty. The complexType allows holding multiple attributes and elements. It contains additional sub-elements and can be left empty.

Difference Between DTD and XSD_Figure 03

Figure 03: new1.xsd file

According to the above XSD file, <xs:element name=”Student”> defines that the element name is Student. The <xs:complexType> defines that the element Student is complex type. The <xs:sequence> defines that the complex type is a sequence of elements. The <xs:element name=”ID” type=”xs:string/> defines that the element ID is of string or text type. The name and Email are also of type string or text.

Key Difference Between DTD and XSD

Figure 04: Student.xml file

Above is the XML file, the location of the new1.xsd file should be included inside xsi:schemaLocation.

What is the Similarity Between DTD and XSD?

  • Both DTD and XSD can be used to define the structure of an XML document.

What is the Difference Between DTD and XSD?

DTD vs XSD

DTD is a set of markup declarations that define a document type for an SGML – family markup language. XSD specifies how to describe the elements in an Extensible Markup Language document formally.
 Stands For
DTD stands for Document Type Definition. XSD stands for XML Schema Definition.
Control on XML Structure
DTD provides less control over the XML structure. XSD provides more control over the XML structure.
 Support for Data Types
DTD does not support data types. XSD supports data types.
Simplicity
DTD is harder than XSD. XSD is simple than DTD.

Summary – DTD vs XSD

XML is a technology for data transferring. DTD and XSD are related to XML. An XML file contains the structure and the content. DTD is a set of markup declarations that define a document type for an SGML – family markup language. XSD specifies how to describe the elements in an Extensible Markup Language document formally. The difference between DTD and XSD is that DTD can be used to define the structure while XSD can be used to define the structure and content.

Reference:

1.“XML Schema (W3C).” Wikipedia, Wikimedia Foundation, 17 Mar. 2018. Available here  
2.“XML DTD – Javatpoint.”, Java T Point. Available here
3.“XML Schema – Javatpoint.”, Java T Point. Available here
4.“Document Type Definition.” Wikipedia, Wikimedia Foundation, 14 Mar. 2018. Available here

Related posts:

Difference Between KDD and Data mining Difference Between Entity and Attribute Difference Between SAP and ORACLE Difference Between Archival and Backup Difference Between Stored Procedure and Function

Filed Under: Database Tagged With: Compare DTD and XSD, DTD, DTD and XSD Differences, DTD and XSD Similarities, DTD Data Types, DTD Definition, DTD Simplicity, DTD vs XSD, DTD XML Structure Control, XSD, XSD Data Types, XSD Definition, XSD Simplicity, XSD XML Structure Control

About the Author: Lithmee

Lithmee Mandula is a BEng (Hons) graduate in Computer Systems Engineering. She is currently pursuing a Master’s Degree in Computer Science. Her areas of interests in writing and research include programming, data science, and computer systems.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Request Article

Featured Posts

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and SARS

Difference Between Coronavirus and SARS

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Covid 19

Difference Between Coronavirus and Covid 19

You May Like

Difference Between Viscoelastic and Viscoplastic

Difference Between Viscoelastic and Viscoplastic

Difference Between SCADA and HMI

Difference Between Operating Leverage and Financial Leverage

What is the Difference Between Gasoline and Petroleum

What is the Difference Between Gasoline and Petroleum

Difference Between Education and Learning

Difference Between Education and Learning

Latest Posts

  • What is the Difference Between Actinic Keratosis and Bowen’s Disease
  • What is the Difference Between Kerion and Favus
  • What is the Difference Between Corpus Callosum and Corpus Luteum
  • What is the Difference Between Ciprofloxacin and Amoxicillin
  • What is the Difference Between HER2 Positive and HER2 Negative
  • What is the Difference Between Hiatal Hernia and Gallbladder Pain
  • Home
  • Vacancies
  • About
  • Request Article
  • Contact Us

Copyright © 2010-2018 Difference Between. All rights reserved. Terms of Use and Privacy Policy: Legal.