XML error messages explained
What the validator's messages mean and how to fix them. These come from libxml2, the parser behind the validator and behind PHP, Python's lxml, xmllint and many other tools, so you will meet the same wording elsewhere. Java and .NET word the same problems differently: their messages are explained too
A business rule failed, such as BR-CO-15 or PEPPOL-EN16931-R001? See business rules explained.
Well-formedness
- Opening and ending tag mismatch An end tag does not match the start tag it should close
- Premature end of data in tag The document ends while an element is still open
- Extra content at the end of the document Something follows the root element, which must be the last thing in the document
- Start tag expected, '<' not found The document does not start with an element
- Document is empty There is no element in the document at all
- Entity not defined The document uses a named entity, like &nbsp;, that XML does not know
- xmlParseEntityRef: no name A bare ampersand (&) in text or an attribute
- Specification mandates value for attribute An attribute without a value, or a space inside a tag name
- AttValue: " or ' expected An attribute value is not in quotes
- Unescaped '<' not allowed in attributes values A < character inside an attribute value
- StartTag: invalid element name A < that does not start a valid element name
- Attribute redefined The same attribute appears twice on one element
- XML declaration allowed only at the start of the document Something comes before <?xml …?>, or there are two declarations
- PCDATA invalid Char value A control character that XML 1.0 does not allow
- Invalid bytes in character encoding The file is not in the encoding it claims (UTF-8 unless it says otherwise)
- Namespace prefix is not defined An element or attribute uses a prefix (inv:) without its xmlns:inv declaration
- Comment not terminated A comment is not closed with -->, or contains --
XML Schema (XSD)
- This element is not expected An element is in the wrong place: out of order, misspelt, or not allowed there
- Is not a valid value of the atomic type A value does not match its data type: a number, a date, a boolean…
- Missing child element(s) A required child element is missing
- The attribute is required but missing An attribute declared with use="required" is not on the element
- The attribute is not allowed An attribute the schema does not declare for this element
- No matching global declaration available for the validation root The schema has no top-level declaration for the document's root element
- [facet 'enumeration'] The value is not an element of the set A value that is not on the schema's list of allowed values
- [facet 'pattern'] The value is not accepted by the pattern A value that does not match the regular expression the schema requires
- [facet 'maxLength'] The value exceeds the allowed length A value longer (or shorter) than the schema allows
- Character content other than whitespace is not allowed Text directly inside an element that may contain only child elements
DTD
- No declaration for element The DTD does not declare an element the document uses
- Element content does not follow the DTD An element's children don't match its content model: order, count or which ones
- No declaration for attribute The DTD does not declare an attribute the element carries
- Element does not carry attribute An attribute declared #REQUIRED in the DTD is missing
RelaxNG
- Did not expect element there An element the RelaxNG pattern does not allow at this point
- Expecting an element, got nothing A required element is missing at the end of its parent
- Type doesn't allow value A value that does not fit the datatype in the RelaxNG pattern
- Invalid attribute for element An attribute the pattern does not allow, or a required one missing
Java (Xerces)
- cvc-complex-type.2.4.a: Invalid content was found starting with element Java found an element where the schema expects a different one: out of order, misspelt, or in another namespace
- cvc-complex-type.2.4.b: The content of element is not complete An element ended before all the children the schema requires appeared
- cvc-complex-type.2.4.d: No child element is expected at this point An element appears after the parent's content is already complete: the schema allows nothing more there
- cvc-complex-type.2.3: Element cannot have character [children] Text appears directly inside an element that may only contain other elements
- cvc-complex-type.3.2.2: Attribute is not allowed to appear in element An element carries an attribute its type in the schema does not declare
- cvc-complex-type.4: Attribute must appear on element A required attribute is missing from an element
- cvc-datatype-valid.1.2.1: Is not a valid value for A value is not in the format of its XML Schema datatype
- cvc-type.3.1.3: The value of element is not valid The text of an element does not satisfy its type; the message before it says why
- cvc-attribute.3: The value of attribute is not valid with respect to its type An attribute's value does not satisfy its type; the message before it says why
- cvc-enumeration-valid: Value is not facet-valid with respect to enumeration A value is not one of the fixed values the schema allows
- cvc-pattern-valid: Value is not facet-valid with respect to pattern A value does not match the regular expression its type requires
- cvc-maxLength-valid: Value with length is not facet-valid with respect to maxLength A value is longer than its type allows
- cvc-elt.1.a: Cannot find the declaration of element The document's root element is not declared in the schema it is validated against
- Content is not allowed in prolog Something other than markup comes before the root element
- The element type must be terminated by the matching end-tag An element is still open when an end tag for another element arrives
- The markup in the document following the root element must be well-formed Something follows the root element: an XML document has exactly one
- XML document structures must start and end within the same entity The document ends while an element, comment or CDATA section is still open
- Premature end of file The parser reached the end of the input before finding a root element
- The entity was referenced, but not declared The document uses a named entity, like &nbsp;, that XML does not define
- The entity name must immediately follow the '&' in the entity reference A bare ampersand (&) in text or in an attribute
- Invalid byte 1 of 1-byte UTF-8 sequence The input is read as UTF-8 but contains bytes that are not valid UTF-8
- The processing instruction target matching "[xX][mM][lL]" is not allowed An XML declaration (<?xml …?>) appears somewhere other than the very start
- The prefix for element is not bound An element uses a namespace prefix that no xmlns declaration defines
- Attribute was already specified for element The same attribute appears twice on one element
- The value of attribute must not contain the '<' character A literal < inside an attribute value
- An invalid XML character (Unicode: 0x…) was found The document contains a control character that XML 1.0 does not allow, even escaped
- Open quote is expected for attribute An attribute value without quotes
- The content of elements must consist of well-formed character data or markup A < in text that does not start a valid tag
- Attribute name must be followed by the ' = ' character An attribute without a value
.NET (System.Xml)
- The element has invalid child element .NET found a child element the schema does not allow at that point: out of order, misspelt, or in another namespace
- The element has incomplete content An element ended before all the children the schema requires appeared
- The element cannot contain text Text appears directly inside an element that may only contain other elements
- The attribute is not declared An element carries an attribute its type in the schema does not declare
- The required attribute is missing A required attribute is missing from an element
- The element is not declared An element, usually the root, is not declared in the schema for its namespace
- The value is invalid according to its datatype A value is not in the format of its XML Schema datatype
- The Enumeration constraint failed A value is not one of the fixed values the schema allows
- The Pattern constraint failed A value does not match the regular expression its type requires
- The actual length is greater than the MaxLength value A value is longer than its type allows
- Data at the root level is invalid The input does not start with markup: it is not XML, or something comes before the root element
- The start tag does not match the end tag An end tag does not match the start tag it should close
- There are multiple root elements More than one element at the top level: an XML document has exactly one root
- Unexpected end of file has occurred The document ends while elements are still open
- Root element is missing The input has no element at all
- Reference to undeclared entity The document uses a named entity, like &nbsp;, that XML does not define
- An error occurred while parsing EntityName A bare ampersand (&) in text or in an attribute
- Invalid character in the given encoding The bytes are not valid in the encoding the document is read with
- Unexpected XML declaration An XML declaration (<?xml …?>) appears somewhere other than the very start
- Is an undeclared prefix An element or attribute uses a namespace prefix that no xmlns declaration defines
- Is a duplicate attribute name The same attribute appears twice on one element
- '<', hexadecimal value 0x3C, is an invalid attribute character A literal < inside an attribute value
- Hexadecimal value 0x…, is an invalid character The document contains a control character that XML 1.0 does not allow
- Name cannot begin with the character A < in text that does not start a valid tag
- Is an unexpected token. The expected token is The parser found a character where XML syntax requires a specific one, most often a quote or an equals sign
- Unexpected end of file while parsing Comment has occurred A comment is never closed, so it runs to the end of the document