July 2002
Intermediate to advanced
864 pages
22h 32m
English
The <simpleType> element allows you to create an element with a content model that is still simple content—that is, content that contains only data and not child elements or mixed content. However, it provides a new level of flexibility: the ability to place restrictions on the existing datatype.
Why is this useful? Well, one example might be declaring an element for inventory. Let's say that you have an inventory item, and you want to create an <inventory> element to represent that inventory. However, because you order the item by the gross, there will never be more than 144 of the item in your inventory, and there can be as few as 0 items in stock. We can use the <simpleType> to declare this kind of element:
<xs:element name="inventory"> ...