XSD Numeric Data Types

For the numeric values, the decimal data types are used.

XML Schema built-in data types:

The most common built-in data types of an XML Schema are:

  • xs:string
  • xs:decimal
  • xs:integer
  • xs:boolean
  • xs:date
  • xs:time

Decimal Data Type:

To specify a numeric value, we can use the decimal data type.

Example: Decimal declaration in a schema:


An element in a document:

99.99

Or:

+99.3132

Or:

-99.3132

Or:

0

Or:

99

Integer Data Type:

To specify a numeric value without a fractional component, the integer data type is used.

Example: Integer declaration in a schema:


An element in a document:

99

Or:

+99

Or:

-99

Or:

0

Numeric Data Types:

Except for the decimal itself, all the data types mentioned below are derived from the Decimal data type.

Name Uses
byte Used to define a signed 8-bit integer.
decimal Used to define a decimal value.
int Used to define a signed 32-bit integer.
integer Used to define an integer value.
long Used to define a signed 64-bit integer.
negativeInteger Used to define an integer containing only negative values (..,-2,-1).
nonNegativeInteger Used to define an integer containing only non-negative values (0,1,2,..).
nonPositiveInteger Used to define an integer containing only non-positive values (..,-2,-1,0).
positiveInteger Used to define an integer containing only positive values (1,2,..).
short Used to define a signed 16-bit integer.
unsignedLong Used to define an unsigned 64-bit integer.
unsignedInt Used to define an unsigned 32-bit integer.
unsignedShort Used to define an unsigned 16-bit integer.
unsignedByte Used to define an unsigned 8-bit integer.

Restrictions on Numeric Data Types:

Restrictions used with Numeric data types:

  • enumeration
  • fractionDigits
  • maxExclusive
  • maxInclusive
  • minExclusive
  • minInclusive
  • pattern
  • totalDigits
  • whiteSpace
Please follow and like us:
Content Protection by DMCA.com