The content of elements must consist of well-formed character data or markup

A < in text that does not start a valid tag.

The message, as Java reports it
The content of elements must consist of well-formed character data or markup.

Why it happens

  • A literal < in text, such as a comparison or code snippet.
  • A tag name starting with a digit, a space or another character not allowed at the start of a name.

How to fix it

Write &lt; for a literal < in text, or wrap the text in a CDATA section; fix the tag name if it is meant to be one.

Java's schema validation (javax.xml.validation.Validator, and JAXB or Spring on top of it) throws at the first error unless you set an ErrorHandler whose error() records the SAXParseException and carries on; each one has getLineNumber() and getColumnNumber(). A well-formedness error ends parsing whatever the handler does.

The same problem in xmlvalid

xmlvalid validates with libxml2, which reports it as StartTag: invalid element name. It checks the whole document in your browser and lists every schema error with its line and column, not only the first.

StartTag: invalid element name

Example

Reports the error
<expr>a < b</expr>
Fixed
<expr>a &lt; b</expr>