The use these elements:
length - the exact length of the lexical value.
minLength - the minimum length of the lexical value.
maxLength - the maximum length of the lexical value.
The maximum must always be bigger than the minimum.
A string with two characters
<xs:simpleType name="code"> <xs:restriction base="xs:string"> <xs:length value="2"/> </xs:restriction> </xs:simpleType>