2.7. Type Substitution

You've seen how XSD supports type derivation through restriction, extension, and list. XSD also supports type substitution: the ability to substitute an element of a derived type in a place where an element of the base type is expected. This maps nicely to how you use interface implementation in VB 6/COM (limited to one interface) and inheritance in VB .NET. For example, consider two VB .NET classes called IceCream and Cake, which both inherit from Dessert as shown in Listing 2.3. The DessertMenu class in Listing 2.3 contains three fields named Item1, Item2, and Item3, each of type Dessert. At runtime, DessertMenu's constructor puts IceCream objects in both Item1 and Item2 and a Cake object in Item3.

Listing 2.3. An example ...

Get Real World XML Web Services: For VB and VB .NET Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.