<xsd:simpleType name="shipNameType">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="40"/>
</xsd:restriction>
</xsd:simpleType>
Here, you use the <xsd:restriction> element to indicate that this simple type restricts the base type xsd:string. Then you use <xsd:maxLength> to indicate the maximum length of the string. There are other ways you can restrict values, for example you could use patterns to specify that a string must contain valid telephone number in the form (703) 606-1234:
<simpleType name="telType">
<restriction base="string">
<pattern value="\(\d{3}\) \d{3}-\d{4}"/>
</restriction>
</simpleType>
You can also restrict the values of numbers by specifying valid ranges. For example, to restrict the Quantity between 1 and 100 you’d write:
<xsd:simpleType name="quantityType">
<xsd:restriction base="xsd:short">
<xsd:minInclusive value="1"/>
<xsd:maxInclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
Comments