# Read XSD data-type errors with concrete examples

Source: https://xsdhub.com/learn/xsd-data-types

Check valid lexical forms for common XSD types with a complete schema. Fix decimal commas, boolean labels and date formats without changing the intended value.

## A field name does not define a type

A value called amount is text until a schema assigns it a type. XSD checks the written representation and any restrictions on the value. A numeric-looking identifier may still belong in xs:string if leading zeros matter. Start with the actual declaration instead of inferring the rule from the element name.

## A small typed schema

This schema requires four values in a fixed order. It uses built-in XSD 1.0 types without additional restrictions. Real schemas may narrow them further with ranges, lengths, enumerations or patterns.

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="reading">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="count" type="xs:integer"/>
        <xs:element name="amount" type="xs:decimal"/>
        <xs:element name="active" type="xs:boolean"/>
        <xs:element name="day" type="xs:date"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
```

## Values that match

The integer is a whole number, the decimal uses a dot, the boolean uses true and the date uses year-month-day. For ordinary modern dates this is a useful starting example. XSD date types also have rules for timezones and years that a simple visual pattern does not fully describe.

```xml
<reading>
  <count>8</count>
  <amount>10.25</amount>
  <active>true</active>
  <day>2026-10-25</day>
</reading>
```

## Decimal and integer mistakes

10,25 and EUR 10.25 are not xs:decimal values. A decimal exponent such as 1e2 is not accepted as xs:decimal either; floating-point types have different lexical rules. xs:integer does not accept 8.0. Convert a localized input only when you know its intended numeric value. Do not strip punctuation blindly from mixed international data.

## Boolean and date mistakes

For xs:boolean, true, false, 1 and 0 are accepted forms; yes and no are not. For xs:date, 25/10/2026 is not the year-month-day representation. A correctly shaped but impossible date such as 2026-02-30 also fails. xs:dateTime is a separate type and includes a T between date and time.

## Check restrictions after the base type

A positiveInteger must be greater than zero, so 0 fails even though it is an integer. A custom decimal restriction might allow a base decimal value but reject its scale or range. Read the simpleType and its facets, then retest one field at a time. Schema success does not establish that a number is the right price or that a date matches an external event.

## Primary references

- [W3C XML Schema datatypes](https://www.w3.org/TR/xmlschema-2/)
