Please enable JavaScript to view this site.

Altova MapForce 2022 Basic Edition

In this step, we will map the data in the source file to the target file. The goal is to map two types of input to the target nodes: (i) source nodes and (ii) data, both of which are mapped simultaneously. Most of the data comes from Books.xml. In our example, we will also supply information about the current date and time using the XPath function current-dateTime.

 

Automatic connections

We will now create a mapping connection between the <book> element in the source component and the <publication> element in the target component. To do this, click the output connector (the small triangle) to the right of the <book> element and drag it to the input connector of the <publication> element in the target. When you do this, MapForce may automatically connect all the child elements of <book> in the source file to the elements with the same names in the target file. In our example, four connections have been created simultaneously (see screenshot below). This feature is called Auto Connect Matching Children and can be disabled and customized if necessary.

MF_Tut1_DesignMap1

You can enable or disable Auto Connect Matching Children in one of the following ways:

 

Click ic-conn-child (Toggle auto connect of children) in the toolbar.

In the Connection menu, click Auto Connect Matching Children.

 

Connect mandatory items

Notice that some of the input connectors in the target component have been highlighted by MapForce in orange, which indicates that these items are mandatory. They are mandatory, because they were set in such a way in the the file's schema. To ensure the validity of the target XML file, provide values for the mandatory items as follows:

 

Connect the <category> element in the source with the <genre> element in the target component.

Connect the <year> element in the source with the <publish_year> element in the target component.

 

Add the current date and time

Finally, you need to supply a value for the <last_updated> element. If you hover over its input connector, you can see that the element is of type xs:dateTime (see screenshot below). Note that, for tips to be displayed, the toolbar button ic-show-lib-info (Show tips) must be enabled. By clicking ic-show-types (Show Data Types) in the toolbar button, you can also make the data type of each item visible at all times.

MF_Tut1_DesignMap2

You can get the current date and time by means of an XSLT2 function current-dateTime. To find this function, type it in the text box located at the bottom of the Libraries window (see screenshot below). Alternatively, double-click an empty area inside the Mapping pane and start typing current-date.

mf_tut1_designmap3_zoom70

To add the function to the mapping, drag the function into the Mapping pane and connect its output to the input of the <last_updated> element (see screenshot below).

MF_Tut1_DesignMap4

You can now validate and save your mapping, as shown in Create and Save Design.

 

© 2015-2021 Altova GmbH