Readablewiki

XML Schema (W3C)

Content sourced from Wikipedia, licensed under CC BY-SA 3.0.

XML Schema (XSD) is a W3C standard that describes the structure and rules for XML documents. It defines what elements and attributes can appear and what data types their values must have (for example, numbers, dates, or strings). XSD supports namespaces and provides data typing beyond what DTDs offer.

Schema files have the .xsd extension and are written in XML. An XML document is validated against a schema using hints in the document (such as xsi:schemaLocation) or by a validator that is given the schema.

Key features:
- Simple types (primitive data types like string, date, integer) and complex types (elements with children and attributes).
- Constraints such as minimum/maximum values, patterns, and length.
- Types can be derived from existing ones by restriction or extension.
- XML Schema 1.1 adds assertions (conditions) using XPath 2.0.

After validation, you get a Post-Schema-Validation Infoset (PSVI), describing the types and validation results. Beyond validation, XSD can be used to generate code to work with XML data and to create documentation of an XML structure.

History: XSD 1.0 was published in 2001; XSD 1.1 became a W3C Recommendation in 2012. It incorporates ideas from DTDs and other early schema efforts (like XDR), which have largely become obsolete in modern tools.

Note: There is no fixed official media type for XSD yet; use application/xml or text/xml as appropriate.


This page was last edited on 2 February 2026, at 06:50 (CET).