Skip to content
AgileLogics

XSD Validation

Checks whether an XML document conforms to a given XSD schema, using libxml's schema validator on our server (no external resources are ever fetched during validation).

How it works

Paste an XML document into the input panel, its XSD schema into the second panel, and click Validate.

Validating XML against an XSD schema

XSD validation checks that an XML document follows the rules in an XML Schema: which elements may appear and in what order, which attributes are required, and what type each value must have (an integer, a date, one of a fixed list). A document can be perfectly well-formed and still fail, which is exactly what this catches before a partner's system rejects your file.

The schema language is defined by the W3C in XML Schema Part 1: Structures and Part 2: Datatypes. This tool validates against version 1.0 of those rules.

This one runs on our server

Most tools on this site work inside your browser. This one doesn't, because browsers have no built-in XSD validator. When you click Validate, both boxes are posted to our server, where PHP loads the XML into a DOMDocument and calls schemaValidateSource, which uses the libxml2 library. The server never loads anything your input points to: external entities and DTDs are not fetched, and neither are schema files named by xs:import or xs:include. The result goes straight back to the page and the tool doesn't store your input. Even so, treat it as sending the data to a third party and leave out anything confidential.

Worked example

The schema below describes an order with a required id, a customer name, a positive quantity and an optional ship date:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="order">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="customer" type="xs:string"/>
        <xs:element name="quantity" type="xs:positiveInteger"/>
        <xs:element name="shipDate" type="xs:date" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="id" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Here's what the validator returned for different versions of the document:

What's wrong with the order Message
Nothing The XML document is valid against the given XSD schema.
Quantity is 0 Element 'quantity': '0' is not a valid value of the atomic type 'xs:positiveInteger'.
No id attribute Element 'order': The attribute 'id' is required but missing.
quantity before customer Element 'quantity': This element is not expected. Expected is ( customer ).
Ship date written 02/11/2026 Element 'shipDate': '02/11/2026' is not a valid value of the atomic type 'xs:date'.
Extra note element at the end Element 'note': This element is not expected. Expected is ( shipDate ).
Root element is invoice Element 'invoice': No matching global declaration available for the validation root.
A closing tag doesn't match Invalid XML: Opening and ending tag mismatch: customer line 1 and order

Schema messages are prefixed "XML does not validate against the schema:". Note the date row: xs:date only accepts the ISO 8601 form 2026-11-02.

One more message you might meet: if your document uses entities defined in its own DOCTYPE (&company; and the like), validation stops with an "Internal error" saying entity references aren't supported. Replace them with their text before validating.

Steps

  1. Paste the XML document into the first box.
  2. Paste the complete schema into the second box. Both are required.
  3. Click Validate and read the first error.
  4. Fix it and validate again until the document passes.

If the message starts with "The XSD schema is invalid", the problem is in the schema itself (for example a misspelled built-in type such as xs:strng, or an XSD 1.1 construct), not in your document. Check the schema's syntax with the XML validator and compare type names against the specification.

Namespaces and the root element

The most common "No matching global declaration" failure is a namespace mismatch. If the schema declares targetNamespace="urn:shop", the document's root has to be in that namespace too. With such a schema, a plain root order element fails, while the same element with xmlns="urn:shop" passes. Also remember that only globally declared elements (direct children of xs:schema) can be the root.

Keep the schema self-contained

Real-world schemas are often split across files with xs:include and xs:import. Those references are never followed here, and the tool tells you the schema refers to an external file rather than guessing. Paste a single schema with all the definitions it uses written inline. If a standard schema is too large to merge by hand, validate it locally with xmllint --schema schema.xsd file.xml, which uses the same libxml2 engine.

Related tools

Once the document validates, the XPath evaluator is useful for checking specific values, and the XML formatter makes long documents readable. For writing or editing schemas with syntax highlighting, use the online XML editor.

Last updated

Frequently asked questions

Is my XML sent to your server?
Yes. Unlike most tools on this site, XSD validation runs on our server: both the XML and the schema are posted there, validated with PHP's DOMDocument (libxml2), and the result is sent back. The tool doesn't save what you paste, but don't submit documents you aren't allowed to share with a third party.
Can my schema use xs:import or xs:include?
No. The validator never loads another file, so a schema containing xs:import, xs:include or an external entity is reported as referring to an external file instead of being validated. Paste one self-contained schema with every type and element it needs defined inline.
Why do I only see one error?
The tool reports the first error libxml2 records. Fix it and validate again; a document with several problems takes several runs.
Does it support XSD 1.1 features like xs:assert?
No. libxml2 implements XML Schema 1.0, so 1.1 constructs such as xs:assert and xs:alternative make the schema itself invalid.
How large can the XML and schema be?
Each box accepts up to 20,000 characters, and the tool is limited to 60 requests per minute. For larger files, validate locally with xmllint --schema.