Quick answer
When the XML is well-formed but does not follow the rules defined in the XSD (wrong element names, wrong types, missing required elements, or wrong order), the validator reports schema mismatch errors.
XML Does Not Match XSD Schema
When the XML is well-formed but does not follow the rules defined in the XSD (wrong element names, wrong types, missing required elements, or wrong order), the validator reports schema mismatch errors.
Common causes
- Element or attribute name not declared in the schema.
- Content does not match the declared type (e.g. text where a number is expected).
- Required child elements missing, or elements in wrong order (e.g. all vs sequence).
How to fix
- Read the validator message: it usually points to the element and the rule that failed.
- Check the XSD for the correct element names, types, and order of children.
- Ensure required elements are present and optional ones are in the allowed order.
Examples
Bad
<root><extra>not in schema</extra></root>
Good
<root><author>Name</author><content>Text</content></root>
FAQ
- What does 'element not allowed' mean in XSD?
- The element at that position is not declared in the schema for the parent element, or the content model does not allow it there.
- Can the order of elements matter in XSD?
- Yes. <xs:sequence> requires a fixed order; <xs:all> allows any order; <xs:choice> allows one of the options.
Fix it now
Try in validator (prefill this example)