Altova MapForce 2025 Basic Edition

Multiple Sources to Multiple Targets

Home Prev Top Next

This tutorial shows you how to map data from multiple source files to multiple target files in the same transformation. To illustrate this technique, we will create a mapping with the following goals:

 

1.To read data from multiple XML files located in the same directory. The files are based on the same source schema.

2.For each source XML file, to generate a new XML target file. The target files will be based on a new target schema.

 

The image below illustrates an abstract model of the data transformation used in this tutorial:

MF_Tut4_BatchProcessMult

 

Broad outline

The starting point of this tutorial is the Tut1_OneToOne.mfd mapping from the first tutorial (screenshot below).

MF_Tut1_DesignMap4

Modify source component

We will modify the component settings of the source component so that it reads data from multiple source files: BookTitle1.xml, BookTitle2.xml, and BookTitle3.xml. Each of these files is based on Books.xsd and stores one book record (see below).

 

BookTitle1.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Books.xsd">
  <book id="1">
     <author>Mark Twain</author>
     <title>The Adventures of Tom Sawyer</title>
     <category>Fiction</category>
     <year>1876</year>
  </book>
</books>

 

BookTitle2.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Books.xsd">
  <book id="2">
     <author>Franz Kafka</author>
     <title>The Metamorphosis</title>
     <category>Fiction</category>
     <year>1912</year>
  </book>
</books>

 

BookTitle3.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Books.xsd">
  <book id="3">
     <author>Herman Melville</author>
     <title>Moby Dick</title>
     <category>Fiction</category>
     <year>1851</year>
  </book>
</books>

 

Modify target component

We will also configure the target component in such a way that the data will be written to multiple target files. The target files will be based on the same schema called Library.xsd. The generated target files will be called Publication1.xml, Publication2.xml, and Publication3.xml (code listings below).

 

Publication1.xml

 

<library>
  <publication>
     <id>1</id>
     <author>Mark Twain</author>
     <title>The Adventures of Tom Sawyer</title>
     <genre>Fiction</genre>
     <publish_year>1876</publish_year>
  </publication>
</library>

 

Publication2.xml

 

<library>
  <publication>
     <id>2</id>
     <author>Franz Kafka</author>
     <title>The Metamorphosis</title>
     <genre>Fiction</genre>
     <publish_year>1912</publish_year>
  </publication>
</library>

 

Publication3.xml

 

<library>
  <publication>
     <id>3</id>
     <author>Herman Melville</author>
     <title>Moby Dick</title>
     <genre>Fiction</genre>
     <publish_year>1851</publish_year>
  </publication>
</library>

 

To carry out the required data transformation, take the steps described in the subsections below.

 

© 2018-2024 Altova GmbH