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

Source: https://xmlvalid.com/errors/attribute-value-must-not-contain-less-than

> A literal &lt; 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

libxml2, which xmlvalid validates with, reports it as [Unescaped '<' not allowed in attributes values](https://xmlvalid.com/errors/unescaped-less-than-in-attribute): `Unescaped '<' not allowed in attributes values`

## Example that fails

```xml
<rule test="a < b"/>
```

## Fixed

```xml
<rule test="a &lt; b"/>
```
