XML Schema (XSD)
What goes wrong in XML Schema (XSD)
The 14 errors this corpus records against XML Schema (XSD) documents, keyed by the message your parser printed. Nothing here is written for this page — each error declares the formats it bites, and this is that declaration read the other way round.
Start with the message you were given
Every entry below states the message our validator emits, verbatim, and a test asserts it still does. If you are holding a broken document rather than a question, XSD validator will tell you which of these you have.Parse errors · 6
These stop the document being read at all. Nothing downstream sees a file with one of them, because it is not XML.
- Attribute redefined
Attribute href redefined (line 1)The same attribute name appears twice on one element, which XML forbids outright. HTML silently keeps the first; XML refuses the document. - Invalid element name
StartTag: invalid element name (line 2)An element name breaks XML's naming rules — usually because it starts with a digit, contains a space, or uses punctuation XML reserves. - Comment not terminated
Comment not terminated (line 3)A comment was opened with <!-- and never closed, so the rest of the file is swallowed as comment text and the reported line is the end, not the fault. - Detected an entity reference loop
Detected an entity reference loopTwo declared entities refer to each other in a cycle. The parser stops rather than expand forever — the same guard that blocks a billion-laughs attack. - Unescaped '<' in an attribute value
Unescaped '<' not allowed in attributes values (line 2)A literal < inside an attribute value. XML forbids it there because the parser cannot tell it from the start of a tag, so it must be written <. - Double hyphen within comment
Double hyphen within comment: <!-- a (line 2)XML forbids -- inside a comment's body, even when the comment is otherwise closed properly. It is one of the specification's genuinely surprising rules.
Schema errors · 8
These appear only once a schema is applied. A document can be perfectly well-formed and fail every one of them.
- The attribute is required but missing
Element 'order': The attribute 'id' is required but missing. (line 2)The schema marks an attribute use="required" and the document does not carry it. Well-formed, and rejected by the first consumer that validates. - The attribute is not allowed
Element 'order', attribute 'ref': The attribute 'ref' is not allowed. (line 2)The document carries an attribute the schema never declared. XSD is closed by default: anything not named is forbidden rather than ignored. - This element is not expected
Element 'note': This element is not expected. (line 10)An element appeared where the schema's content model does not allow one — an extra child, an unknown child, or the right children in the wrong order. - Missing child element(s)
Element 'order': Missing child element(s). Expected is ( line ). (line 2)The element ended before its content model was satisfied. The schema names what it was still waiting for, which makes this the most actionable schema error. - Not a valid value of the atomic type
Element 'issued': '31/01/2026' is not a valid value of the atomic type 'xs:date'. (line 4)The element's text does not fit its declared datatype. Dates are the usual culprit, because XSD accepts exactly one format and humans write several. - The value is not an element of the set
Element 'state': [facet 'enumeration'] The value 'pending' is not an element of the set {'open', 'closed'}. (line 5)The value is not one of the permitted options. The message lists the full set, which makes it the one schema error that tells you the answer outright. - The value is not accepted by the pattern
Element 'code': [facet 'pattern'] The value 'widget' is not accepted by the pattern '[A-Z]{2}-\d{4}'. (line 7)The value does not match the regular expression the schema constrains it with — the usual guard on SKUs, references, IBANs and postcodes. - No matching global declaration for the validation root
Element 'invoice': No matching global declaration available for the validation root. (line 2)The validator could not find the root element in the schema at all — nearly always a namespace mismatch rather than a genuinely unknown element.
Back to XML Schema (XSD) — root element, namespaces, constraints and a worked example.
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.