Altova MapForce 2024 Enterprise Edition

Connect Source and Target

Home Prev Top Next

In this step, we will map the data in the source file to the target file. 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, press and hold the output connector (the small triangle) to the right of the <book> element and drag the line to the input connector of the <publication> element in the target. When you do this, MapForce may automatically connect all the child nodes of <book> in the source file to the nodes 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). To be able to see tips, press the ic-show-lib-info toolbar button. By clicking ic-show-types (Show Data Types) in the toolbar, 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 the current-dateTime function. 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. Then 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.

 

© 2017-2023 Altova GmbH