No matching global declaration available for the validation root

The schema has no top-level declaration for the document's root element.

The message, as the validator reports it
Element 'invoice': No matching global declaration available for the validation root.

Why it happens

  • The wrong schema for this document.
  • A namespace mismatch, the most common cause. The schema has a targetNamespace and the document's root is not in it (no xmlns="…", or a different URI), or the document has a namespace the schema doesn't. The message then shows the root as {namespace}name.
  • The root element is declared only locally, inside another element, not as a global xs:element.

How to fix it

Compare the root element's name and namespace with the schema's global xs:element declarations and its targetNamespace. The namespace URI has to match character for character.

Example

Validated against order.xsd, below.

Reports the error
<invoice currency="EUR">
  <id>A-1</id>
  <qty>1</qty>
</invoice>
Fixed
<order currency="EUR">
  <id>A-1</id>
  <qty>1</qty>
</order>
order.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="order">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="id" type="xs:string"/>
        <xs:element name="qty" type="xs:int"/>
        <xs:element name="status" type="Status" minOccurs="0"/>
        <xs:element name="code" type="Code" minOccurs="0"/>
        <xs:element name="note" type="Short" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="currency" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:simpleType name="Status">
    <xs:restriction base="xs:string">
      <xs:enumeration value="open"/>
      <xs:enumeration value="paid"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="Code">
    <xs:restriction base="xs:string">
      <xs:pattern value="[A-Z]{3}-[0-9]{4}"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="Short">
    <xs:restriction base="xs:string">
      <xs:maxLength value="10"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>