Reference
XSD datatypes
29 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 · 6
- 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.
- 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.
- xs:NameAn XML name, which may contain a colon. Rarely the type you want — NCName usually is.
- xs:languageA BCP 47 language tag, checked by shape rather than against the registry.
Numeric types · 7
- 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 distinction from xs:nonNegativeInteger.
- xs:nonNegativeIntegerAn integer of 0 or more. The right type for counts, where zero is a real answer.
- xs:unsignedIntAn unsigned 32-bit integer: 0 to 4,294,967,295.
- 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.
- xs:timeA time of day, seconds mandatory, with 24:00:00 legal and 24:00:01 not.
- 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 the dates that are genuinely partial.
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'.
- xs:anyURIA URI reference — validated so loosely that almost any string passes, which makes it weaker than it looks.
- xs:base64Binary and xs:hexBinaryThe two ways to carry bytes in XML. base64Binary tolerates whitespace; hexBinary does not.
- 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 — so 01 and 1 are the same number.
- minLength, maxLength and lengthBounds on size — measured in characters for strings, list items for lists, and bytes for binary.
- 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 trailing zeros do not count.
- whiteSpacepreserve, replace or collapse — applied before every other facet, which is why it changes what they see.
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.