Altova MapForce 2023 Basic Edition

This example shows you how to generate dynamically multiple XML files from a single source XML file. The accompanying mapping for this example is available at the following path: <Documents>\Altova\MapForce2023\MapForceExamples\Tutorial\Tut-ExpReport-dyn.mfd.

 

The source XML file (available in the same folder as the mapping) consists of the expense report for a person called "Fred Landis" and contains five expense items of different types. The aim of the example is to generate a separate XML file for each of the expense items listed below.

dyn-xml2xml2

mf-ExpReport.xml (as shown in XMLSpy Grid view)

As the type attribute defines the specific expense item type, this is the item we will use to split up the source file. To achieve the goal of this example, do the following:

 

1.Insert a concat function (you can drag it from the core | string functions library of the Libraries pane).

2.Insert a constant (on the Insert menu, click Constant) and enter ".xml" as its value.

3.Insert the auto-number function (you can drag it from the core | generator functions library of the Libraries pane).

4.Click the File ( btn_file ) or File/String ( btn_file_string ) button of the target component and select Use Dynamic File Names Supplied by Mapping.

5.Create the connections as shown below and then click the Output pane to see the result of the mapping.

tut-ExpReport-dyn-MFBAS

Tut-ExpReport-dyn.mfd (MapForce Basic Edition)

Note that the resulting output files are named dynamically as follows:

 

The type attribute supplies the first part of the file name (for example, "Travel").

The auto-number function supplies the sequential number of the file  (for example, "Travel1", "Travel2", and so on).

The constant supplies the file extension, which is ".xml", thus "Travel1.xml" is the file name of the first file.

© 2017-2023 Altova GmbH