Based on data type token
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.java2s.com" xmlns="http://www.java2s.com" elementFormDefault="qualified"> <xs:simpleType name="string255"> <xs:restriction base="xs:token"> <xs:maxLength value="255" /> </xs:restriction> </xs:simpleType> <xs:simpleType name="string32"> <xs:restriction base="xs:token"> <xs:maxLength value="32" /> </xs:restriction> </xs:simpleType> </xs:schema>