Introduction to XML Schemas
XML Schemas are documents that are used to define and validate the content and structure of XML data, just as a database schema defines and validates the tables, columns, and data types that make up a database.
An XML Schema defines and describes certain types of XML data by using the XML Schema definition language (XSD). XML Schema elements (elements, attributes, types, and groups) are used to define the valid structure, valid data content, and relationships of certain types of XML data. XML Schemas can also provide default values for attributes, and elements. For more information, see the World Wide Web Consortium (W3C) Web site (http://www.w3.org/).
You use an XML Schema to guarantee consistency among certain types of XML data that is shared between applications and organizations. An XML Schema can be used as a contract for data exchange between two applications. Organizations can publish schemas that describe the format of the XML their applications produce and consume. Other organizations and applications that wish to exchange data can then build their applications around these schemas so their xml messages will be understood.
For example, a purchase order represented in XML can be validated with an XML Schema before it is sent between buyer and seller. This validation verifies that all of the elements (individual pieces) of data exist, are in the expected sequence, and are all of the correct data type. This ensures that the recipient of the purchase order will be able to interpret the data correctly when it is received.
XML Schemas in Visual Studio conform to the W3C recommendation regarding XML Schema based on the XML Schema definition language (XSD). These are some of the advantages that XML Schemas have over previous technologies, such as DTDs:
- XML Schemas use XML syntax, so you do not need to learn a new syntax to define your data structure.
- XML Schemas support reusable types and allow you to create new types using inheritance.
- XML Schemas allows you to group elements to control the recurrence of elements and attributes.
For more information about schemas and how the elements they represent constrain data, see XML Elements, Attributes, and Types.
XML Schemas and Data | Creating XML Schemas and Datasets | XML Schema Primer on the World Wide Web Consortium Web Site (http://www.w3.org/) | XML Designer | Walkthrough: Creating an XML Schema with the XML Designer | Introduction to Data Access with ADO.NET | Introduction to Datasets