O'Reilly logo

Special Edition Using XML, Second Edition by - et al. David Gulbransen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

<simpleType>

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"> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required