xs:length

Purpose Specifies a length constraint for a data item. The value of the constraint is specified in the value attribute.
Parent element xs:restriction
Child elements None
Attributes fixed, value
Restrictions

The xs:length element may not be specified together with the xs:maxLength element or the xs:minLength element.

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 attribute specifies the 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 of a string type based on a restriction using the xs:length element. The defined type only accepts strings that are 8 characters long:

<xs:simpleType name="code">
   <xs:restriction base="xs:string">
     <xs:length value="8"/>
   </xs:restriction>
</xs:simpleType>