“Overview” section states that the XML Schema Working Group, by charter, is assigned to look into a more informative constraint on the XML document than is provided by DTDs, namely one that would also, among other things:
Support both primitive and complex datatypes
Support restrictions or extensions on datatypes
Be written in XML
For example, consider the following snippet of a DTD:
<!ELEMENT book (title, author, publisher, price)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT price (#PCDATA)*>
This could appear in XML Schema format as the following XSD file:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:bk=http://www.mypublishsite.com/book>
<xsd:annotation>
<xsd:documentation xml:lang="en">
Possible XML Schema equivalent of a DTD shown in Listing 1.
</xsd:documentation>
</xsd:annotation>
<xsd:element name="title" type="xsd:string" minOccurs="1"
maxOccurs="1"/>
<xsd:element name="author" type="xsd:string" minOccurs="1"
maxOccurs="unbounded"/>
<xsd:element name="publisher" type="xsd:string" minOccurs="1"
maxOccurs="unbounded"/>
<xsd:element name="price" type="xsd:string" minOccurs="0"
maxOccurs="*"/>
<xsd:element name="Book"/>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bk:title"/>
<xsd:element ref="bk:author"/>
<xsd:element ref="bk:publisher"/>
<xsd:element ref="bk:price"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
The “Purpose” section of the “XML Schema Requirements” Note succinctly states the purpose of a schema:
The purpose of a schema is to define and describe a class of XML documents by using these constructs to constrain and document the meaning, usage and relationships of their constituent parts: datatypes, elements and their content, attributes and their values, entities and their contents and notations. Schema constructs may also provide for the specification of implicit information such as default values. Schemas document their own meaning, usage, and function. Thus, the XML schema language can be used to define, describe and catalogue XML vocabularies for classes of XML documents.
The “Usage Scenarios” section of the Note lists the types of XML applications and activities that should benefit from an XML schema:
Publishing and syndication
Electronic commerce transaction processing
Supervisory control and data acquisition
Traditional document authoring/editing governed by schema constraints
Use schema to help query formulation and optimization
Open and uniform transfer of data between applications, including databases
Metadata Interchange
The “Design Principles” section set forth specific goals for the XML Schema language to be met in order to meet the design requirements. These included that it must be a simple, self-describing language in XML that was widely usable by applications across the Internet and was coordinated with core XML specifications such as XML Information Set, Links, Namespaces, Pointers, Style and Syntax.
The final section, “Requirements,” lists the structural requirements of what the XML Schema language must define, the datatype requirements of the language, and the conformance requirements. The XML Schema Working Group took these requirements and produced a number of working drafts, which culminated in the May 2001 “W3C Recommendation for XML Schema.” This document consists of three parts: “XML Schema Part 0: Primer”; “XML Schema Part 1: Structures”; and “XML Schema Part 2: Datatypes.”