Schema Summary
This sample shows how a complextype may be extended, and how the base and extended types can be manipulated in code.

Schema Details
The Schema
A global base type Address is defined (all base types must be global). The elements CAN_Address and GBR_Address then extended Address in order to add additional elements.
The Person element contains a child element HomeAddress of type Address. In place of Address any type that is based on Address (including Address itself) can be used (CAN_Address and GBR_Address).
If an element is added to Person:HomeAddress of a type other than the Address, then we need to identify the type of the element used (for validation purposes), this means placing a xs:type="" attribute against the element. This is automatically done for you by the generated classes.

Generated Code
The element Address is a base element to CAN_Address and GBR_Address, and Address can be created as an element in its own right. This means that where ever Address can be used CAN_Address and GBR_Address can be used in its place. In order to implemenent this in the generated code, an abstract base class IAddress is introduced. All of the classes generated from Address, CAN_Address and GBR_Address implement this IAddress interface.


Sample Description
The sample demonstrates the use of the derived type Can_Address. Note the type specified in Person is 'Address' however any element deriving from it may used in its place.

Sample XML File
 Sample3.xml

Sample Code
 Read Sample
 Write Sample

XSD Source Files
 DerivedByExtension.xsd
 Schema Diagrams

Generated Files
 Address.vb
 CAN_Address.vb
 GBR_Address.vb
 IAddress.vb
 Person.vb

Main Menu Samples List