XML Schema Tutorial


XML Schema

An XML Schema describes the structure of an XML document.

In this tutorial you will learn how to create XML Schemas and how to use XML Schemas in your application.

XML Schema Example

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="to" type="xs:string"/>
      <xs:element name="from" type="xs:string"/>
      <xs:element name="heading" type="xs:string"/>
      <xs:element name="body" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

</xs:schema>


What You Should Already Know

Before you continue you should have a basic understanding of the following:

  • HTML
  • XML
  • A basic understanding of DTD

If you want to study these subjects first, find the tutorials on our Home page.


What is an XML Schema?

The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD.

An XML Schema:

  • defines elements that can appear in a document
  • defines attributes that can appear in a document
  • defines which elements are child elements
  • defines the order of child elements
  • defines the number of child elements
  • defines whether an element is empty or can include text
  • defines data types for elements and attributes
  • defines default and fixed values for elements and attributes

XML Schema is a W3C Recommendation

XML Schema became a W3C Recommendation 02. May 2001.



SHARE THIS PAGE

COLOR PICKER

colorpicker





Search w3schools.com:

Translate w3schools.com: