Merging Data from Multiple Schemas
This example illustrates how to merge multiple files into a single target file. Specifically, it merges multiple source components having different schemas to a target schema. To merge an arbitrary number of files using the same schema, see Processing Multiple Input or Output Files Dynamically.
The CompletePO.mfd shows how three XML files are merged into one purchasing order XML file. The file is available in the following folder: C:\Users\<username>\Documents\Altova\MapForce2022\MapForceExamples.
Note that multiple source component data are combined into one target XML file, CompletePO.xml.
•ShortPO is a schema with an associated XML instance file and contains only customer number and article data, such as line item, number and amount. (Note that there is only one customer in this file.)
•Customers is a schema with an associated XML instance file and contains customer number and customer information details, such as name and address information.
•Articles is a schema with an associated XML instance and contains article data, such as article name, number and price.
•CompletePO is a schema file without an instance file; all the data is supplied by the three XML instance files. The hierarchical structure of this file makes it possible to merge and output all XML data.
This schema file has to be created in an XML editor such as XMLSpy, it is not generated by MapForce (although it would be possible to create if you had a CompletePO.xml instance file).
The structure of CompletePO is a combination of the source XML file structures.
The filter component (Customer) is used to find/filter the data where the customer numbers are identical in both the ShortPO and Customers XML files, and pass on the associated data to the target CompletePO component.
•The CustomerNr in ShortPO is compared with the Number in Customers using the equal function.
•As ShortPO only contains one customer (number 3), only customer and article data for customer number 3 can be passed on to the filter component.
•The node/row parameter of the filter component passes the Customer data to "on-true" when the bool parameter is true, specifically, when the same number has been found, in this case customer number 3.
•The rest of the customer and article data are passed on to the target schema through the two other filter components.