Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
XML is not unfamiliar to us, it has a wide range of uses in enterprise-class applications. Specifically, no longer said, the following describes the difference between dtd,xsd and XSD as an example to see the definition and use of spring.
1.DTD (documnet Type Definition) A DTD, a document type definition, is an XML constraint schema language that is a validation mechanism for XML files and is part of the XML file composition.
DTDs are an effective way to ensure that the XML document is well-formed by comparing XML documents and DTD files to see if the document conforms to the specification and whether the elements and labels are used correctly. A DTD document contains the definition rules for elements, the rules for defining relationships between elements, the attributes that an element can use, and the entity or symbol rules that can be used.
DTD versus xsd: DTDs are written using non-XML syntax.
DTDs are not extensible, namespaces are not supported, and only a very limited number of data types are available.
2.XSD (XML Schemas Definition) The XML schema language is also XSD. The XML Schema describes the structure of the XML document.
An XML document can be validated with a specified XML schema to check whether the XML document meets its requirements. The XML schema allows the document designer to specify the structure and content allowed by an XML document, and to check whether an XML document is valid. The XML schema itself is an XML document that conforms to the XML syntax structure. It can be parsed with a common XML parser.
An XML schema defines the elements that appear in the document, the attributes that appear in the document, the child elements, the number of child elements, the order of the child elements, whether the element is empty, the data type of the element and attribute, the default and fixed values of the element or attribute.
XSD is the reason for DTD substitution, one is that the future conditions can be expanded, two is richer and more useful than DTDs, three is written in XML, four is support data type, and five is support namespace.
The advantages of XML schema:
1) XML Schema XML-based, no specific syntax
2) XML schema can parse and process like other XML files
3) The XML schema provides a richer data type than the DTD.
4) XML schema provides an extensible data model.
5) XML schema supports integrated namespaces
6) XML schema supports attribute groups.
(1) The schema element is the root element of all XML Schema schema documents, and it is used to declare that the XML document is an XML Schema document. The schema document itself is also an XML document with its own namespace of xmlns:xsd= "Http://www.w3.org/2001/XMLSchema", where XSD is prefixed.
(2) Schema targetnamespace defines the namespace of the new element and attribute defined by the schema. That is, it restricts the defined XML model by restricting the defined element, or the namespace of the property.
use of the XSD file in the configuration file in 4.Spring
When you validate an XML instance document using an XML Schema document, you must specify the XML that corresponds to the namespace, in addition to declaring the namespace (xmlns= "Http://www.springframework.org/schema/beans") The location where the schema document is stored.
Use the SchemaLocation property to specify the storage location of the XML Schema document for the namespace, which contains two parts, part of the namespace URI, and the second part is the XML schema file location or URL address identified by the namespace
(xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ spring-beans-2.5.xsd)
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.