What is XML Schema (XSD)?

 

XML Schema Definition (XSD) language is the current standard schema language for all XML documents and data. On May 2, 2001, the World Wide Web Consortium (W3C) published XSD in its version 1.0 format.

The XML Schema definition language (XSD) enables you to define the structure and data types for XML documents. An XML Schema defines the elements, attributes, and data types that conform to the World Wide Web Consortium (W3C) XML Schema Part 1: Structures Recommendation for the XML Schema Definition Language. The W3C XML Schema Part 2: Datatypes Recommendation is the recommendation for defining data types used in XML schemas. The XML Schema Reference (XSD) is based on the W3C 2001 Recommendation specifications for Datatypes and for Structures.

An XML Schema is composed of the top-level schema element. The schema element definition must include the following namespace:

http://www.w3.org/2001/XMLSchema  

The schema element contains type definitions (simpleType and complexType elements) and attribute and element declarations.

In addition to its built-in data types (such as integer, string, and so on), XML Schema also allows for the definition of new data types using the simpleType and complexType elements.

simpleType
A type definition for a value that can be used as the content (textOnly) of an element or attribute. This data type cannot contain elements or have attributes.

complexType
A type definition for elements that can contain attributes and elements. This data type can contain elements and have attributes.

In the remainder of this XSD Starter Kit, we will look at how to get started with XSD. For in-depth learning or reading on XSD, refer to the following draft recommendations that describe it:

  • XML Schema Part 0: Primer

  • XML Schema Part 1: Structures

  • XML Schema Part 2: Datatypes

Drafts of each of these are available at the World Wide Web Consortium (W3C) Web site (http://www.w3.org).