Liquid XML Data Binder (C++, Java, VB6) / Examples / Derived By Extension / Example Usage / Use of Derived Base GBR_Address Type / Visual Basic 6 Sample : Derived By Extension
In This Topic
    Visual Basic 6 Sample : Derived By Extension
    In This Topic
    Schema Summary
    This sample shows how a complex type 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 implement 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 GBR_Address. Note the type specified in Person is 'Address' however any element deriving from it may used in its place.

    Sample XML File

     Sample2.xml

    Sample Code
     Read Sample
     Write Sample

    XSD Source Files
     DerivedByExtension.xsd
     Schema Diagrams

    Generated Files
     Address.cls
     CAN_Address.cls
     GBR_Address.cls
     Person.cls

    Main Menu Samples List