XSD facet
minInclusive, maxInclusive and the exclusive pair
Range bounds for ordered types. Inclusive includes the endpoint; exclusive does not, and mixing them up is an off-by-one you will not see.
minInclusive and maxInclusive bound a value with the endpoint allowed; minExclusive and maxExclusive exclude it. They apply to any ordered type — numbers, dates, times and durations.
You cannot specify both minInclusive and minExclusive on the same type. Pick the one that says what you mean.
- Lexical space
- A value of the type being constrained.
- Derives from
- Primitive type
- Category
- Constraining facets
What catches people out
- Inclusive and exclusive cannot both be set for the same end.
- They work on dates and durations too, and duration comparison is only partial — a range on xs:duration can reject values you expected to pass.
- The bound is a value of the type, so a maxInclusive on xs:decimal must itself be a valid decimal.
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.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="t"><xs:restriction base="xs:integer"><xs:minInclusive value="1"/><xs:maxInclusive value="10"/></xs:restriction></xs:simpleType>
<xs:element name="v" type="t"/>
</xs:schema>Related
- xs:decimalAn exact decimal number with arbitrary precision — and no exponent notation, which is the usual reason a value is rejected.
- 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: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:durationA length of time in ISO 8601 form, starting with P — and only partially ordered, because months have no fixed length.
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.