Liquid XML Data Binder (C++, Java, VB6) / Examples / Sample : Derived By Extension
In This Topic
    Sample : Derived By Extension
    In This Topic
    Summary
    This sample shows how a complex type may be extended, and how the base and extended types can be manipulated in code.

    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.

    XSD Source Files
     DerivedByExtension.xsd
     Schema Diagrams

    Sample Name Description C++ C# Java VB.Net VB6
    Use of Base Address Type 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). Example   Example   Example   Example   Example  
    Use of Derived Base GBR_Address Type 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. Example   Example   Example   Example   Example  
    Use of Derived Can_Address Type 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. Example     Example   Example   Example  

    Main Menu