Example: Pass-Through Active
The mapping used in this example (ChainedReports.mfd) is available in the <Documents>\Altova\MapForce2023\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-item type="Travel" expto="Marketing">
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 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.
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.
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.
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.
Settings of the target component
If you preview the mapping by clicking the Output tab 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.
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.
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 ).