[XSD Learning]xsd Introduction

Source: Internet
Author: User

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

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.