Java Reference
In-Depth Information
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="InitialString">
<xs:restriction base="xs:string">
<xs:minLength value="0" />
<xs:maxLength value="1" />
<xs:pattern value="[A-Za-z]?" />
</xs:restriction>
</xs:simpleType>
<!--Just simple constraint to keep it this short.
Not good enough for real world.-->
<xs:simpleType name="CardNumber">
<xs:restriction base="xs:string">
<xs:pattern value="\^(\d{4}[- ]){3}\d{4}|\d{16}$" />
<xs:minLength value="10" />
<xs:maxLength value="16" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="Authorization">
<xs:sequence>
<xs:element name="amount" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
This schema defines two global elements: creditCard and authorization . The credit card
is a composite type consisting of three elements: cardNumber , name , and expirationDate .
Each of these types is in turn specified by other types.
The cardNumber is defined as a simpleType with a restriction on the allowable structure of
the number and a minimum and maximum length. The cardholder name actually points to
another complex type, Name , which defines a first, last, and middle initial. These are then as-
signed their own constraints for acceptable data length and acceptable characters.
The second element, authorization , defines an amount of money for which a given card can
be authorized. It's simpler because I wanted to show a custom type for the return as well, but
I didn't want to be redundant.
Search WWH ::




Custom Search