XSD NumericData Types



Decimal Data Type

The decimal data type is used to specify a numeric value.

Below is an example of a decimal declaration in a schema.

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

The element in the document should look like this:

<prize>999.50</prize>

Or like this:

<prize>+999.5450</prize>

Or like this:

<prize>-999.5230</prize>

Or like this:

<prize>0</prize>

Or like this:

<prize>14</prize>

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


Integer Data Type

The integer data type is used to specify a numeric value without a fractional component.

Below is an example of an integer declaration in a schema.

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

The element in the document should look like this:

<prize>999</prize>

Or like this:

<prize>+999</prize>

Or like this:

<prize>-999</prize>

Or like this:

<prize>0</prize>


Numeric Data Types

Note that all the data types below are derived from the decimal data type (except decimal itself)!

Name Description
byte Signed 8-bit integer
decimal Decimal number
int Signed 32-bit integer
integer Integer value
long Signed 64-bit integer
negativeInteger Integer containing only negative values (.., -2, -1.)
nonNegativeInteger Integer containing only non-negative values (0, 1, 2, ..)
nonPositiveInteger Integer containing only non-positive values (.., -2, -1, 0)
positiveInteger Integer containing only positive values (1, 2, ..)
short Signed 16-bit integer
unsignedLong Unsigned 64-bit integer
unsignedInt Unsigned 32-bit integer
unsignedShort Unsigned 16-bit integer
unsignedByte Unsigned 8-bit integer


Restrictions on Numeric Data Types

Restrictions that can be used with numeric data types:

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