All along the project in the XML format of the decision to use the DTD format, until recently discovered, do not know when all have been converted to XSD for judgment and verification, so today specifically looking for information to see, have to say, for this kind of information, W3cschool is really a good database, Many things can be found directly on the top of the material.
XSD is a substitute for DTDs, mainly because of the following reasons:
- XML Schema can be extended for future requirements
- XML Schema is more complete and more powerful
- XML Schema-based XML authoring
- XML Schema Support data type
- XML Schema supports namespaces
It has to be said that the concept here is not useful until we know the specific situation, and can only be experienced with further understanding.
<?XML version= "1.0"?><Xs:schemaXmlns:xs= "Http://www.w3.org/2001/XMLSchema"targetnamespace= "http://www.w3school.com.cn"xmlns= "http://www.w3school.com.cn"elementFormDefault= "qualified"><xs:elementname= "Note">
<!--indicates that the root node is note--> <Xs:complextype> <xs:sequence> <xs:elementname= "to"type= "Xs:string"/> <xs:elementname= "from"type= "Xs:string"/> <xs:elementname= "Heading"type= "Xs:string"/> <xs:elementname= "Body"type= "Xs:string"/>
<!--indicates that there are four elements in the note node, all formatted as strings--
</xs:sequence> </Xs:complextype></xs:element></Xs:schema>
The above is the simplest XSD format, mainly used to define the primary node and the child nodes within the node, the corresponding XML file is:
<?XML version= "1.0"?><Notexmlns= "http://www.w3school.com.cn"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://www.w3school.com.cn note.xsd">< to>George</ to>< from>John</ from><Heading>Reminder</Heading><Body>Don ' t forget the meeting!</Body></Note>
View Code
The corresponding DTD checksum file format for this XML file is:
<! ELEMENT Note (to, from, heading, body) > <! ELEMENT to (#PCDATA) > <! ELEMENT from (#PCDATA) > <! ELEMENT Heading (#PCDATA) > <! ELEMENT Body (#PCDATA) >
As seen from the above file, the XSD format is more complex and more hierarchical, but supports more data types and can be specified directly as strings.
[XSD Learning]xsd Introduction