Skip to main content
XMLDir

Search 309 pages — tools, formats, elements, namespaces, directory, comparisons, XPath, datatypes, glossary, parse errors, schema errors, use cases, blog and product.

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-1

    What the engine returns

    Invalid as xs: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-01

    What the engine returns

    Valid as xs: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.

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.