# cvc-type.3.1.3: The value of element is not valid

Source: https://www.xmlvalid.com/errors/cvc-type-3-1-3

> The text of an element does not satisfy its type; the message before it says why.

The message, as Java reports it: `cvc-type.3.1.3: The value 'two' of element 'qty' is not valid.`

## Why it happens

- It always follows a more specific message about the same value: [cvc-datatype-valid.1.2.1](/errors/cvc-datatype-valid-1-2-1) for a wrong format, or a facet such as [cvc-enumeration-valid](/errors/cvc-enumeration-valid), [cvc-pattern-valid](/errors/cvc-pattern-valid) or [cvc-maxLength-valid](/errors/cvc-maxlength-valid).

## How to fix it

- Fix the reason given in the previous message; this one only adds which element held the value. The two count as one problem. If you only see this one, your error handler or log is dropping the first.
- 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://www.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
<order currency="EUR">
  <id>A-1</id>
  <qty>two</qty>
</order>
```

## Fixed

```xml
<order currency="EUR">
  <id>A-1</id>
  <qty>2</qty>
</order>
```
