Skip to main content
XMLDir

Search 261 pages — tools, formats, elements, namespaces, XPath, datatypes, glossary, parse errors, schema errors, use cases, blog and product.

XSD datatype

xs:int

A signed 32-bit integer: −2,147,483,648 to 2,147,483,647. The bounded type most schemas should use and most do not.

xs:int carries the range of a signed 32-bit integer, and xs:long the range of a signed 64-bit one. Both are derived from xs:integer by fixing minInclusive and maxInclusive.

Choosing xs:int over xs:integer moves an overflow from a runtime surprise to a validation error, which is where you want it.

Lexical space
Optional sign, then digits, within the 32-bit signed range.
Derives from
xs:long
Category
Numeric types
Facets
minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration, whiteSpace, totalDigits, fractionDigits

What validates

Every literal below is put through the schema validator on each test run, against the schema at the foot of this page.

  • 0
  • 2147483647
  • -2147483648
  • -1

What does not

  • 2147483648

    One past the 32-bit maximum.

  • -2147483649

    One past the 32-bit minimum.

  • 3.0

    Integers have no decimal point.

What catches people out

  • The bounds are inclusive and asymmetric: the minimum is one further from zero than the maximum.
  • xs:int is 32-bit and xs:long is 64-bit. Neither is named after the number of bits, which catches people coming from C.
  • A value one past the boundary is a validation error, which is the entire reason to use this type rather than xs:integer.

The schema used

This is the exact schema the literals above are validated against. Paste it into the validator with one of them to see the result yourself.

schema.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="v" type="xs:int"/>
</xs:schema>

Open the XSD validator

Related

All 29 datatypes and facets

Get started

Bring order to the XML your team can't afford to ignore.

Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.