XSD datatype
xs:positiveInteger
An integer of 1 or more. Zero is not positive, which is the distinction from xs:nonNegativeInteger.
xs:positiveInteger has minInclusive fixed at 1; xs:nonNegativeInteger has it at 0. The difference is exactly whether zero is allowed, and choosing the wrong one is a common schema bug — a quantity of 0 is usually meaningful, a quantity of −1 is not.
Both are unbounded above, because both derive from xs:integer.
- Lexical space
- Optional plus sign, then digits, with a value of 1 or greater.
- Derives from
xs:nonNegativeInteger- Category
- Numeric types
- Facets
- minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration, whiteSpace, totalDigits, fractionDigits
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:element name="v" type="xs:positiveInteger"/>
</xs:schema>Related
- xs:nonNegativeIntegerAn integer of 0 or more. The right type for counts, where zero is a real answer.
- xs:integerA whole number of unlimited size. It derives from xs:decimal, not from a machine int — so it has no range at all.
- 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.
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.