XSD Numeric Data Type

Decimal data types are used for numbers.

Decimal data types

Decimal data types are used to specify a number.

Below is an example of a decimal number declaration in a certain scheme.

<xs:element name="prize" type="xs:decimal"/>

The elements in the document should look something like this:

<prize>999.50</prize>

Or something like this:

<prize>+999.5450</prize>

Or something like this:

<prize>-999.5230</prize>

Or something like this:

<prize>0</prize>

Or something like this:

<prize>14</prize>

Note:The maximum number of decimal digits you can specify is 18.

Integer data types

Integer data types are used to specify numbers without a fractional component.

Below is an example of an integer declaration in a certain scheme.

<xs:element name="prize" type="xs:integer"/>

The elements in the document should look something like this:

<prize>999</prize>

Or something like this:

<prize>+999</prize>

Or something like this:

<prize>-999</prize>

Or something like this:

<prize>0</prize>

Numeric data types

Please note that all data types listed below are derived from the decimal data type (except for decimal itself)!

Name Seconds
byte 8-bit integers with both positive and negative signs
decimal Decimal number
int 32-bit integers with both positive and negative signs
integer Integer value
long 64-bit integers with both positive and negative signs
negativeInteger Integers containing only negative values ( .., -2, -1.)
nonNegativeInteger Integers containing only non-negative values (0, 1, 2, ..)
nonPositiveInteger Integers containing only non-positive values (.., -2, -1, 0)
positiveInteger Integers containing only positive values (1, 2, ..)
short A 16-bit integer with sign
unsignedLong A 64-bit integer without sign
unsignedInt A 32-bit integer without sign
unsignedShort A 16-bit integer without sign
unsignedByte An 8-bit integer without sign

Constraints (Restrictions) for Numeric Data Types

Constraints That Can Be Used with Numeric Data Types:

  • enumeration
  • fractionDigits
  • maxExclusive
  • maxInclusive
  • minExclusive
  • minInclusive
  • pattern
  • totalDigits
  • whiteSpace