Copy-All connections map data between complex structures (nodes with children items) that are very similar or identical. The main benefit of "Copy-All" connections is that they simplify the mapping workspace (one "thick" connection is created instead of multiple).
On the mapping, a "Copy-All" connection appears as a single bold line (with input and output "forks" for each child item) that connects two identical or similar structures.
When you draw a mapping connection between two structures on the mapping, MapForce creates a "Copy-All" connection automatically if it detects that the source and target structure are assignment compatible (that is, when both structures are either of the same type, or the target is a subtype of the source type). At mapping runtime, all instance data will be copied from the source to the target recursively, including children.
To create a "Copy-All" connection manually, right-click an existing connection between two similar nodes with child items, and select Copy-All (Copy Child Items) from the context menu.
Note the following:
|•||In contexts where a "Copy-All" connection is not meaningful or not supported, it is not possible to create this kind of connection manually.|
|•||A "Copy-All" connection cannot be created to the root element of an XML/Schema component.|
|•||When creating "Copy-All" connections between a schema and a parameter of a user-defined function, the two components must be based on the same schema. It is not necessary that they both have the same root elements, however.|
For an example of a "Copy-All" connection created manually, take the following steps:
|1.||Create a new mapping.|
|2.||On the Insert menu, click XML Schema/File and browse for the books.xml file located in the folder <Documents>\Altova\MapForce2019\MapForceExamples\Tutorial\.|
|3.||On the Insert menu, click XML Schema/File and browse for the library.xsd file located in the folder <Documents>\Altova\MapForce2019\MapForceExamples\Tutorial\.|
|4.||Draw a mapping connection between the book node of the "books" component to the publication node of the "library" component.|
|5.||Right-click the new connection, and select Copy-All (Copy Child Items) from the context menu.|
If there are slight differences between the source and the target structures, the "Copy-All" connection will enumerate, at mapping runtime, the source items (such as elements and attributes) and will copy only those that exist in the target type. This is repeated recursively.
For example, in the mapping above, only two child items are identical between the two structures (author and title) and thus they are mapped to the target. The item id is not included automatically because it is an attribute in the source and an element in the target. If you need to map, for example, category to genre, the "Copy-All" connection is no longer possible, because these are different items.
When an input connector (the small triangle to the side of the component) receives a "Copy-All" connection, it cannot accept any other connections. In the example above, if you attempt to create a connection between category and genre, MapForce prompts you to either replace it, or duplicate the input.
Duplicating input is meaningful only if you want the target to accept data from more than one input, which is not required here (see also Duplicating Input). If you choose to replace the "Copy-All" connection, a message box prompts you again to either resolve or delete the "Copy-All" connection.
Click Resolve copy-all connection if you want to replace the "Copy-All" connection by standard individual target-driven connections to corresponding child items. If you prefer to remove the "Copy-All" connection completely, click Delete child connections.
© 2019 Altova GmbH