Schemas and validity
XML Schema (XSD)
The W3C schema language: a grammar written in XML itself, with datatypes, namespaces and a type system.
XSD is what most machine-to-machine XML validates against, because it is the one with a real type system. It brings namespaces, inheritance, and a datatype library precise enough to reject "2026-1-1" as a date — which is also where most of the surprises live.
Its verbosity is the standard complaint and the reason RELAX NG exists. Its type system is the reason it stayed: a schema that says a value is an xs:decimal with two fraction digits is doing work no other schema language does as directly.
- Defined in
- XSD 1.0 / 1.1
- Category
- Schemas and validity
- Also written
- XSD, W3C XML Schema, .xsd
Shown, not asserted
All 2 claims are executed on every test run, against the same engines the tools use. If the behaviour changes, the test fails rather than this page quietly becoming wrong.
The datatype library is the point: a nearly-right date is rejected.
schema.xsd <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="v" type="xs:date"/> </xs:schema>value 2026-1-1What the engine returns
Invalid asxs:date.The zero-padded form passes.
schema.xsd <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="v" type="xs:date"/> </xs:schema>value 2026-01-01What the engine returns
Valid asxs:date.
What catches people out
- A schema with no targetNamespace validates only unnamespaced documents, which is the most common reason a schema seems to match nothing.
- xsi:schemaLocation in an instance document is a hint. A validator is free to ignore it, and most do unless configured.
- XSD 1.1 added assertions and conditional type assignment, but tool support is uneven — check before relying on them.
Where it bites
A definition on its own is trivia. These are the pages where this term decides whether a document works.
- FormatsXML Schema (XSD)The format page: root element, namespace and the constraints that bite.
- NamespacesXML Schema Definition (XSD)The namespace every schema declares.
- ToolsXSD validatorValidate a document against a schema here.
- Datatypesxs:dateThe type used above, with the literals that pass and fail.
Related terms
- ValidA well-formed document that also conforms to a declared grammar — a DTD, an XSD schema or a RELAX NG grammar.
- Target namespaceThe namespace a schema's declarations belong to, named by the targetNamespace attribute on xs:schema.
- Simple typeA schema type whose values are text with no child elements and no attributes — a string, a number, a date, or a restriction of one.
- Complex typeA schema type for elements that have children, attributes, or both — everything a simple type cannot describe.
- FacetA constraint that narrows a simple type: a length, a range, a regular expression, a list of permitted values.
- Schema locationAn attribute in an instance document pairing a namespace URI with a URL where a schema for it may be found — a hint, not an instruction.
Get started
Bring order to the XML your team can't afford to ignore.
Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.