XSD facet
minLength, maxLength and length
Bounds on size — measured in characters for strings, list items for lists, and bytes for binary.
length fixes an exact size; minLength and maxLength bound it. What is being counted depends on the type: characters for string types, octets for base64Binary and hexBinary, and items for list types.
That variation is the trap. maxLength 10 on an xs:base64Binary means ten decoded bytes, not ten characters of Base64.
- Lexical space
- A non-negative integer.
- Derives from
- Primitive type
- Category
- Constraining facets
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:string"><xs:minLength value="3"/><xs:maxLength value="8"/></xs:restriction></xs:simpleType>
<xs:element name="v" type="t"/>
</xs:schema>Related
- xs:stringAny sequence of legal XML characters, with whitespace preserved exactly. The only string type that does not touch your value.
- xs:base64Binary and xs:hexBinaryThe two ways to carry bytes in XML. base64Binary tolerates whitespace; hexBinary does not.
- xs:tokenA string trimmed of leading and trailing whitespace, with internal runs collapsed to one space. The right type for most identifiers.
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.