Reference
XSD datatypes
39 entries covering the built-in types and the facets that constrain them — with every example literal put through the validator rather than asserted.
Why a value you are sure about gets rejected
Most schema failures are lexical rather than semantic. "2026-1-1" is not a date because months must be zero-padded, "1.5e3" is not a decimal because decimals have no exponent, and "True" is not a boolean because the literal is lowercase. Each page below lists what passes and what does not, both checked. Validate your own.String types · 8
- xs:stringAny sequence of legal XML characters, with whitespace preserved exactly. The only string type that does not touch your value.
- xs:normalizedStringA string with tabs, newlines and carriage returns replaced by spaces — but not trimmed and not collapsed, so 'a b' stays four spaces wide.
- xs:tokenA string trimmed of leading and trailing whitespace, with internal runs collapsed to one space. The right type for most identifiers.
- xs:NCNameAn XML name with no colon — the type of every element and attribute name, and of the local half of a QName. It cannot start with a digit.
- xs:NameAn XML name, which may contain a colon. Rarely the type you want: 'a:b:c' is a valid xs:Name but not a valid QName, because it checks characters only.
- xs:languageA BCP 47 language tag, checked by shape rather than against the registry — so invented tags validate, and 'en_GB' fails where 'en-GB' passes.
- xs:NMTOKENOne XML name token: name characters without the rule that the first character must be a letter or underscore, which is why '42' is a valid NMTOKEN.
- xs:NMTOKENSA whitespace-separated list of NMTOKEN values, with list whitespace collapsed before validation. Commas are not separators, and length counts items.
Numeric types · 15
- xs:decimalAn exact decimal number with arbitrary precision — and no exponent notation, which is the usual reason a value is rejected.
- xs:integerA whole number of unlimited size. It derives from xs:decimal, not from a machine int — so it has no range at all.
- xs:intA 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:positiveIntegerAn integer of 1 or more. Zero is not positive, which is the whole distinction from xs:nonNegativeInteger — and it is still unbounded above.
- xs:nonNegativeIntegerAn integer of 0 or more, and the right type for counts where zero is a real answer. '-0' validates too, because its value is zero.
- xs:unsignedIntAn unsigned 32-bit integer: 0 to 4,294,967,295. The maximum is roughly four billion, not two — which is the point of the unsigned range.
- xs:nonPositiveIntegerAn integer of zero or less. Zero is allowed and positive values are not, it is unbounded below, and the name describes the value rather than a minus sign.
- xs:negativeIntegerAn integer strictly below zero. Zero, including -0, is rejected, because facets constrain the value and not the spelling. There is no lower bound.
- xs:longA signed 64-bit integer from −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 — a range JavaScript Number cannot represent exactly.
- xs:shortA signed 16-bit integer from −32,768 to 32,767, bounds inclusive. The name describes storage width, not a number of decimal digits.
- xs:byteA signed 8-bit integer from −128 to 127 — not an arbitrary octet value. The type for the 0–255 your platform calls a byte is xs:unsignedByte.
- xs:unsignedLongAn unsigned 64-bit integer from zero to 18,446,744,073,709,551,615 — a maximum that does not fit in a signed 64-bit database column.
- xs:unsignedShortAn unsigned 16-bit integer from zero to 65,535 — not the same range as signed xs:short, which is the confusion this type exists to catch.
- xs:unsignedByteAn integer from zero to 255, the XSD type that actually models an octet value — though it is still serialized as decimal text, not raw binary.
- xs:double and xs:floatIEEE binary floating point, with exponents, infinities and NaN — and the rounding that makes it wrong for money.
Date and time types · 5
- xs:dateTimeA date and time in ISO 8601 form, requiring the T separator and zero-padding. Timezone is optional, which causes more trouble than it saves.
- xs:dateA calendar date, zero-padded, with an optional timezone that almost nobody expects it to have — which means it is not always a fixed 24-hour period.
- xs:timeA time of day, seconds mandatory, with 24:00:00 legal and 24:00:01 not. The 'HH:MM' that every time picker produces is not a valid xs:time.
- xs:durationA length of time in ISO 8601 form, starting with P — and only partially ordered, because months have no fixed length.
- xs:gYear and friendsGregorian fragments — a year, a month, a day, or a pair of them — for dates that are genuinely partial. gMonth is '--08', with both hyphens.
Other types · 5
- xs:QNameA namespace-qualified name — and the one type whose meaning depends on namespace declarations in scope, not just on the characters.
- xs:booleanExactly four literals: true, false, 1 and 0. Not 'yes', not 'True', not 'on' — which is how a Python or spreadsheet serialiser breaks a schema.
- xs:anyURIA URI reference, validated so loosely that almost any string passes — including 'not a url'. Nothing is ever fetched, and nothing is resolved.
- xs:base64Binary and xs:hexBinaryThe two ways to carry bytes in XML. base64Binary tolerates whitespace; hexBinary does not, and rejects an odd number of digits outright.
- xs:ID, xs:IDREF and xs:IDREFSDocument-scoped unique identifiers and references to them — with uniqueness enforced across the whole document, not per element.
Constraining facets · 6
- patternA regular expression the whole value must match — anchored implicitly, and in XSD's own dialect rather than PCRE.
- enumerationA closed list of permitted values, compared in the value space rather than the lexical one — so on a numeric type '01' and '1' both match.
- minLength, maxLength and lengthBounds on size, measured in characters for strings, list items for lists and bytes for binary. length cannot be combined with either of them.
- minInclusive, maxInclusive and the exclusive pairRange bounds for ordered types. Inclusive includes the endpoint; exclusive does not, and mixing them up is an off-by-one you will not see.
- fractionDigits and totalDigitsDecimal precision limits, counted on the value rather than the literal — so '1.50' has one fraction digit, and trailing zeros never count.
- whiteSpacepreserve, replace or collapse — applied before every other facet, which is why patterns and enumerations see the processed value, not yours.
Hit a schema error rather than a datatype question? The schema error reference is keyed by the message the validator prints.
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.