The value of attribute must not contain the '<' character

A literal < inside an attribute value.

The message, as Java reports it
The value of attribute "test" associated with an element type "rule" must not contain the '<' character.

Why it happens

  • A comparison or an HTML snippet written into an attribute as is.
  • XML built by string concatenation without escaping.

How to fix it

Write &lt; instead of < in attribute values. An XML API escapes it for you.

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 Unescaped '<' not allowed in attributes values. It checks the whole document in your browser and lists every schema error with its line and column, not only the first.

Unescaped '<' not allowed in attributes values

Example

Reports the error
<rule test="a < b"/>
Fixed
<rule test="a &lt; b"/>