Differences between DTD and XSD in XML and their application details

Source: Internet
Author: User
DTD is an effective method to ensure that the XML document format is correct. you can compare the XML document and DTD file to see whether the document complies with the specifications, and whether the elements and labels are correctly used. 1. DTD (rule net Type Definition)
Document Type Definition (DTD) is an XML constraint mode language. it is a validation mechanism for XML files and is part of XML files.
DTD is an effective method to ensure that the XML document format is correct. you can compare the XML document and DTD file to see whether the document complies with the specifications, and whether the elements and labels are correctly used.
A dtd document contains:
The definition rules of elements, the definition rules of the relationship between elements, the attributes that can be used by elements, and the entity or symbol rules that can be used. Compared with XSD, DTD is written in non-XML syntax. DTD cannot be expanded. it does not support namespaces and only provides very limited data types.

There is no difference between 1.0 and 2.0

 
 

2. XSD (XML Schemas Definition)
The XML Schema language is XSD. XML Schema describes the structure of an XML document. You can use a specified XML Schema to verify an XML document to check whether the XML document meets its requirements. Document designers can specify the structures and content allowed by an XML document through XML Schema, and check whether an XML document is valid accordingly. XML Schema is an XML document, which conforms to the XML syntax structure. You can use a common XML parser to parse it. An XML Schema defines: the elements in the document, the attributes in the document, the sub-elements, the number of sub-elements, the order of sub-elements, whether the elements are empty, the data type, element, or attribute of the elements and attributes the default and fixed values.

XSD is a substitute for DTD. One is that it can be expanded according to future conditions, the other is richer and more useful than DTD, the third is to write in XML, and the fourth is to support data types, 5. namespace is supported.

Advantages of XML Schema:
1) XML Schema is based on XML and there is no special syntax
2) XML Schema can be parsed and processed like other XML files
3) XML Schema provides richer data types than DTD.
4) XML Schema provides an extensible data model.
5) XML Schema supports a comprehensive namespace
6) XML Schema supports attribute groups.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.