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:decimal

An exact decimal number with arbitrary precision — and no exponent notation, which is the usual reason a value is rejected.

xs:decimal represents a value exactly, with no binary floating-point rounding. It is the right type for money and for anything where 0.1 + 0.2 must equal 0.3.

Its lexical space is deliberately narrow: an optional sign, digits, an optional decimal point and more digits. No exponent, no thousands separators, no currency symbols. '1.5e3' is a valid xs:double and not a valid xs:decimal.

Lexical space
Optional sign, then digits with at most one decimal point. No exponent.
Derives from
Primitive type
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.

  • 14.50
  • -0.001
  • +3
  • 0
  • 123456789012345678901234567890.5

What does not

  • 1.5e3

    Exponent notation belongs to xs:float and xs:double.

  • 1,500.00

    A thousands separator is not part of the lexical space.

  • €14.50

    A currency symbol is not a number.

  • NaN

    xs:decimal has no NaN — that is a float/double concept.

  • (the empty string)

    An empty value is not a decimal.

What catches people out

  • No exponent notation. This is the single most common rejection.
  • Arbitrary precision: there is no maximum. A 40-digit decimal is valid, and your language's native type may not hold it.
  • fractionDigits constrains the number of decimal places, and it counts the value rather than the literal — '1.50' has fractionDigits 2, '1.5' has 1.

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.