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.