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 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 validates

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

  • 5

What does not

  • 0

    Below the minInclusive in the example schema.

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.

schema.xsd
<?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>

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.