Liquid XML Data Binder (C++, Java, VB6) / Examples / Derived By Extension / Example Usage / Use of Base Address Type / VB.Net Sample : Derived By Extension
In This Topic
    VB.Net 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 base Address type. Note other elements derived from Address may be used in its place (See Samples 2 and 3).

    Sample XML File

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