Altova MapForce 2023 Basic Edition

Mapping Rules and Strategies

Home Prev Top Next

In general, MapForce maps data in an intuitive way, but you may come across situations where the output contains too many or too few items. This chapter is meant to help you avoid situations when the mapping produces undesired output due to incorrect connections or mapping context.

 

Mapping rules

In order to be valid, a mapping must include at least one source and at least one target component. A source component is one that reads data, typically from a file or database. A target component is one that writes data, typically to a file or database. If you attempt to save a mapping where the above is not true, an error appears in the Message window: "A mapping requires at least two connected structures, for a example, a schema or a database structure".

 

To create a data mapping, you draw mapping connections between items in the source and target components.

 

All mapping connections that you draw make together a mapping algorithm. At mapping runtime, MapForce evaluates the algorithm and processes data based on it. The integrity and the efficiency of the mapping algorithm depends primarily on the connections. You can also tweak some settings at mapping level, at component level, or even at connection level, but, essentially, the mapping connections determine how your data is processed.

 

Keep in mind the following rules when creating connections:

 

1.When you draw a connection from a source item, the mapping reads data associated with that item from the source file or database. The data may have zero, one, or multiple occurrences (in other words, it may be a sequence, as further described below). For example, if the mapping reads data from an XML file containing books, the source XML file may contain zero, one, or multiple book elements. In the mapping below, notice that the book item appears only once on the mapping component, even though the source (instance) file may contain multiple book elements, or none.

mfdBooksToLibrary-BAS

2.When you draw a connection to a target item, the mapping generates instance data of that kind. If the source item contains simple content (for example, string or integer) and if the target item accepts simple content, MapForce copies the content to the target item and, if necessary, converts the data type. Zero, one, or multiple values can be generated, depending on the incoming source data, see the next bullet.

3.For each (instance) item in the source, one (instance) item is created in the target. This is the general mapping rule in MapForce. Taking the mapping above as example, if the source XML contains three book elements, then three publication elements will be created on the target side. Note that there are also a few special cases, see Sequences.

4.Each connection creates a current mapping context. The context determines which data is available at the current moment, for the current target node. The context, therefore, determines which source items are actually copied from the source to the target component. By drawing or omitting a connection, you may inadvertently change the current context and thus affect the output of the mapping. For example, your mapping might unnecessarily call a database or a Web service multiple times in the same mapping execution. This concept is further described below, see The mapping context.

© 2017-2023 Altova GmbH