Using Anonymous Type Definitions

So far, all the element declarations we've used in the ch05_07.xsd schema have used the type attribute to indicate the new element's type. But what if you want to use a type only once? Do you have to go to the trouble of declaring it and naming it, all to use it in only one element declaration?

It turns out that there is an easier way. You can use an anonymous type definition to avoid having to define a whole new type that you'll reference only once. Using an anonymous type definition simply means that you enclose a <xsd:simpleType> or <xsd:complexType> element inside an <xsd:element> element declaration. In this case, you don't assign an explicit value to the type attribute in the <xsd:element> element because ...

Get Real World XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.