xs:minLength — Facet to define a minimum length.
<xs:minLength fixed = xs:boolean : “false” id = xs:ID value = xs:nonNegativeInteger {any attributes with non-schema namespace} > Content: (xs:annotation?) </xs:minLength>
May be included in: xs:restriction (simple type), xs:restriction (simple content)
May be used as facet for: xs:anyURI, xs:base64Binary, xs:ENTITIES, xs:ENTITY, xs:hexBinary, xs:ID, xs:IDREF, xs:IDREFS, xs:language, xs:Name, xs:NCName, xs:NMTOKEN, xs:NMTOKENS, xs:normalizedString, xs:NOTATION, xs:QName, xs:string, xs:token
xs:minLength
is a facet that allows definition of
the minimum length expressed in a unit that depends on the datatype.
For most of the datatypes, the unit is the character as defined in
the XML 1.0 Recommendation (i.e., Unicode characters defined by
ISO/IEC 10646 that may be represented on more than 8 bits). The
exceptions are the binary datatypes (xs:hexBinary
and xs:base64Binary
), for which lengths are
expressed in number of bytes (8 bits) of binary data, and all the
list datatypes, for which lengths are expressed in number of list
items.
xs:minLength
constrains the value space. In
practice, this means that it is checked after whitespace replacement
and collapsing, as defined by the xs:whiteSpace
facet.
This is a logical length, which often has no direct relation on the size of storage needed for the value.
It is forbidden to define both xs:minLength
and
xs:length
in the same restriction step. Although
not explicitly specified in the Recommendation, it
doesn’t make sense to define several
xs:minLength
facets in a single restriction step
either.
Within a restriction step, xs:minLength
is also
dependent on xs:maxLength
, since using
inconsistent values leads to datatypes with empty value spaces.
xs:minLength
must restrict the value space of its
base type, and its value must be greater than the value of
xs:minLength
of its base type if defined.
Although not specified in the Recommendation,
xs:minLength
interacts with
xs:length
and shouldn’t be used
if xs:length
is defined for its base type.
Fixing the xs:minLength
facet
doesn’t fix the xs:length
facet.
To fix both facets, define two restriction steps since it is
forbidden to apply these two facets in the same restriction step.