Altova MapForce 2024 Basic Edition

The mapping used in this example (ChainedReports.mfd) is available in the <Documents>\Altova\MapForce2024\MapForceExamples\Tutorial\ folder. This mapping processes an XML file called ReportA.xml that contains travel expenses and looks as shown below. For simplicity, the namespace declaration and some expense-item elements have been omitted:

 

<?xml version="1.0" encoding="UTF-8"?>
<expense-report currency="USD" detailed="true">
  <Person>
    <First>Fred</First>
    <Last>Landis</Last>
    <Title>Project Manager</Title>
    <Phone>123-456-78</Phone>
    <Email>f.landis@nanonull.com</Email>
  </Person>
  <expense-item type="Travel" expto="Development">
    <Date>2003-01-02</Date>
    <Travel Trav-cost="337.88">
        <Destination/>
    </Travel>
    <description>Biz jet</description>
  </expense-item>
  <expense-item type="Lodging" expto="Sales">
    <Date>2003-01-01</Date>
    <Lodging Lodge-cost="121.2">
        <Location/>
    </Lodging>
    <description>Motel mania</description>
  </expense-item>

  <expense-item type="Travel" expto="Marketing">
    <Date>2003-02-02</Date>
    <Travel Trav-cost="2000">
        <Destination/>
    </Travel>
    <description>Hong Kong</description>
  </expense-item>
</expense-report>

ReportA.xml

The goal of the mapping it to produce, based on the file above, two further reports:

 

ReportB.xml - this report should contain only those travel expenses that are of type "Travel".

ReportC.xml - this report should contain only those travel expenses that are of type "Travel" and do not exceed 1500.

 

To achieve this goal, the intermediate component of the mapping (component B) has the pass-through button btn_component_pass-through_pressed active, as shown below. This causes the mapping to be executed in stages: from A to B, and then from B to C. The output created by the intermediate component will be used as input for the mapping between B and C.

mf_passthrough_02

The names of generated output files at each stage in the mapping chain is determined by the settings of each component. (To open the component settings, right-click it, and then select Properties from the context menu). Namely, the first component is configured to read data from an XML file called ReportA.xml. Because this is a source component, the Output XML File field is irrelevant and it was left empty.

mf_passthrough_03

Settings of the source component

As shown below, the second component (ReportB) is configured to create an output file called ReportB.xml. Notice that the Input XML File field is grayed out. When pass-through is active (as in this example), the Input XML File field of the intermediate component is automatically deactivated. An input file name need not exist for the mapping to execute, because the output created at this stage in the mapping is stored in a temporary file and reused further in the mapping. Also, if an Output XML File is defined (as illustrated below), then it is used for the file name of the intermediate output file. If no Output XML File is defined, a default file name will be automatically used.

mf_passthrough_04

Settings of the intermediate component

Finally, the third component is configured to produce an output file called ReportC.xml. The Input XML File field is irrelevant here, because this is a target component.

mf_passthrough_05

Settings of the target component

If you preview the mapping by clicking the Output pane in the mapping window, two files are shown in the output, as expected:

 

1.ReportB.xml, which represents the result of the mapping A to B

2.ReportC.xml, which represents the result of mapping B to C.

 

To select which of the two generated output files should be displayed in the Output window, either click the arrow buttons, or select the desired entry from the dropdown list.

mf_passthrough_06

Generated output files

When the mapping is executed by MapForce, the setting "Write directly to final output file" (configured from Tools | Options | General) determines whether the intermediate files are saved as temporary files or as physical files. Note that this is only valid when the mapping is previewed directly in MapForce. Had this mapping been executed by MapForce Server or by generated code, actual files would be produced at each stage in the mapping chain.

 

If StyleVision is installed, and if a StyleVision Power Stylesheet (SPS) file has been assigned to the target component (as in this example), then the final mapping output can be viewed (and saved as) HTML, RTF file. To generate and view this output in MapForce, click the tab with the corresponding name.

mf_passthrough_07

Generated HTML output

Note that only the output of the final target component in the mapping chain is displayed. To display StyleVision output of intermediary components, you would need to deactivate the pass-through button, and preview the intermediate component (as shown in Example: Pass-Through Inactive ).

© 2017-2023 Altova GmbH