xs:minLength

Purpose

This element is a restriction facet used to specify an inclusive minimum length constraint for a data item.

The actual value of the constraint is given by the value attribute.

Parent element xs:restriction
Child elements None
Attributes fixed, value
Restrictions

The following restrictions apply:

  • The xs:minLength element may not be specified simultaneously with the xs:length element.

  • If an xs:maxLength element is specified along with the xs:minLength element in the same restriction, the value attribute of the xs:minLength element must be less than or equal to the value attribute of the xs:maxLength element.

  • The following update schema constraint applies to the xs:minLength element:

    The value of xs:minLength is not permitted to become more restrictive after update schema.

    This means that if an xs:minLength element is specified for the base type, the value attribute of this element in the derivation must not be less than the value attribute of the base type.

Attributes
Name Type Description
fixed xs:boolean If "true", the value of this facet must not be changed in a derived type. Default: "false".
value xs:nonNegativeInteger

The value of the xs:minLength facet is measured in different units depending on the base type of the restriction:

  • Binary data
    (such as "hexBinary" or "base64Binary"):

    Octets

  • List data
    (such as "IDREFS", "ENTITIES", "NMTOKENS"):

    Number of list items

  • String types:
    Number of characters

The value attribute specifies the minimum length of the restricted type in number of octets of binary data (if the type is hexBinary or base64Binary) or number of characters otherwise.

Example

The following example shows a simple type definition based on a restriction using the xs:minLength element:

<xs:simpleType name="input-field">
  <xs:restriction base="xs:string">
    <xs:minLength value="8"/>
  </xs:restriction>
</xs:simpleType>

This defines a string to be used as an input field with a length of at least 8 characters.