Altova MapForce 2024 Basic Edition

This topic explains how to use derived types in mappings. Derived types are defined in the W3C XML Schema Specification (Section 2.5.2). For a brief overview of primitive and derived types, see the Microsoft documentation. In order to use derived types in a mapping, you must specify the xsi:type attribute in your XML file (e.g., <Address xsi:type="UK-Address">).


Possible scenario

This subsection describes a possible scenario of using a derived type. For example, we have a company with two branches: one in the UK and the other in the US. Now we would like to have two lists (UKCustomers and USCustomers), each of which will include information about the respective branch address and all the customers associated with this branch.


Definition of derived types

The screenshots below illustrate the definition of derived types called US-Address and UK-Address (XMLSpy Schema view). The UK-Address and UK-Address elements have the same base type called AddressType that includes the Name, Street, and City elements. In the US-Address element, the base type has been extended to include Zip and State, whereas the UK-Address element includes the base type and the Postcode element. For illustration purposes, we will map only the UK-Address element to the target file.

xsi1 UKAddress

Derived type in a mapping

The instructions below show how to map data from the derived type. Our goal is to map information about the UK office to the UKCustomers element. The sample files are available in the Tutorial folder.


1.Go to the Insert menu, click XML Schema/File, and open DerivedTypeSource.xml. This XML file is based on DerivedTypeSource.xsd.

2.Insert the target file called DerivedTypeTarget.xsd. Note that the target schema does not have to include the xsi:type attribute.

3.Click the btn_derived_type button next to the Address element in the source component. This button indicates that derived types exist for this element in the schema.

4.The Derived Types dialog box (see screenshot below) allows you to select any derived types available for this specific element. In our sample mapping, we want only UK-Address to be mapped.


5.As soon as you select the check box next to the UK-Address derived type, a new element called Address xsi:type="UK-Address" appears in the component.

6.Now connect the nodes as shown in the mapping below.



Clicking the Output pane will show the following result:



  <BranchOffice>Sleuth Corp. UK</BranchOffice>

  <Street>222 Baker St</Street>


  <Postcode>NW1 6XE</Postcode>



The sample mapping is saved as Tutorial\DerivedType.mfd. You can also add another source XML file that includes information about the customers in the UK and map this data to the Customers node in the target component. This way, the UKCustomers element will include information about the UK address and all the customers associated with this branch.


© 2018-2024 Altova GmbH