XML Schema (XSD)

XML Schema, whose schema documents conventionally use the .xsd extension, is the W3C language for describing the structure and content of XML documents. It plays the same validating role as a Document Type Definition — declaring which elements and attributes are allowed and how they may be combined — but does so with far more expressive power. The W3C Recommendation for its structures component states that it “substantially reconstructs and considerably extends the capabilities found in XML 1.0 document type definitions (DTDs),” positioning XML Schema as the deliberate successor to the DTD.

The specification comes in two parts. XML Schema Part 1: Structures defines the schema definition language itself — how to declare elements, attributes, complex and simple types, and the constraints that relate them. XML Schema Part 2: Datatypes defines a built-in library of data types such as strings, integers, dates, and booleans, along with a framework for deriving new types by restriction or extension. The two parts depend on each other: Structures relies on Datatypes for complete functionality.

XML Schema differs from the DTD in three decisive ways. First, a schema is itself an XML document, so it can be authored, validated, and processed with ordinary XML tools, unlike the DTD’s separate syntax. Second, it is built around XML namespaces, allowing documents that mix vocabularies to be described and validated without name collisions. Third, it provides a real type system: elements and attributes can be constrained to specific data types, value ranges, patterns, and enumerations, enabling validation that goes well beyond the structural checks a DTD could express. The Recommendation notes the schema language is itself represented in XML 1.0 and uses namespaces.

The first version, XML Schema 1.0, became a W3C Recommendation on 2 May 2001, with a Second Edition published on 28 October 2004. A later revision, XML Schema Definition Language (XSD) 1.1, became a Recommendation in April 2012, adding features such as assertions and conditional type assignment for finer-grained validation. Across these versions the core role stayed constant: a standardized, XML-native way to define and enforce document contracts.

XML Schema became the schema language of choice for many XML-based standards, including SOAP-based web services, where service contracts were expressed with XSD, and document formats such as Office Open XML, whose structure is defined by schemas. By combining namespaces, an XML-native syntax, and rich datatypes, XML Schema gave the XML ecosystem a validation mechanism strong enough for machine-to-machine data exchange, completing the transition away from the simpler DTD inherited from SGML.

Sources

Last verified June 8, 2026