# cvc-attribute.3: The value of attribute is not valid with respect to its type

Source: https://xmlvalid.com/errors/cvc-attribute-3

> An attribute's value does not satisfy its type; the message before it says why.

The message, as Java reports it: `cvc-attribute.3: The value 'two' of attribute 'qty' on element 'item' is not valid with respect to its type, 'int'.`

## Why it happens

- The value is in the wrong format for the attribute's datatype: Xerces reports that first as [cvc-datatype-valid.1.2.1](/errors/cvc-datatype-valid-1-2-1).
- It breaks a facet of the type: an enumeration, a pattern, a length.

## How to fix it

- Fix the value as the previous message says; this one adds the attribute, the element and the declared type.
- 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 [Is not a valid value of the atomic type](https://xmlvalid.com/errors/not-a-valid-value-of-the-atomic-type): `Element 'qty': 'two' is not a valid value of the atomic type 'xs:int'.`

## Example that fails

```xml
<item qty="two"/>
```

## Fixed

```xml
<item qty="2"/>
```
