# cvc-datatype-valid.1.2.1: Is not a valid value for

Source: https://xmlvalid.com/errors/cvc-datatype-valid-1-2-1

> A value is not in the format of its XML Schema datatype.

The message, as Java reports it: `cvc-datatype-valid.1.2.1: 'two' is not a valid value for 'integer'.`

## Why it happens

- A number with a decimal comma, a thousands separator or a unit, where the schema expects `xs:decimal` or `xs:int`.
- A date in a local format: `xs:date` is `2026-10-17`, `xs:dateTime` is `2026-10-17T09:30:00`.
- An empty element for a numeric or date type, or a boolean written as `yes` (`xs:boolean` takes `true`, `false`, `1` or `0`).

## How to fix it

- Write the value in the datatype's format. Xerces names the built-in type it checked against, which can be the base of the declared one: `integer` here for an element declared `xs:int`. The next message, [cvc-type.3.1.3](/errors/cvc-type-3-1-3) or [cvc-attribute.3](/errors/cvc-attribute-3), names the element or attribute that holds the value.
- 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
<order currency="EUR">
  <id>A-1</id>
  <qty>two</qty>
</order>
```

## Fixed

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