Copy-all connections map data between complex structures (i.e., nodes with children items) that are similar or the same. Copy-all connections are only possible for identical formats (e.g., JSON to JSON or XML to XML). This principle also applies to all text components: flat files, FlexText and EDI files. Since these formats are all text files, you can combine any of them and create a copy-all connection between EDI and FlexText files, for example. For details about the formats that can be used as sources and targets, see this topic.
The main benefit of copy-all connections is that they visually simplify the mapping workspace: one connection, represented by a thick line, is created instead of multiple connections (see screenshot below).
If the source and target files have nodes with the same structure, a copy-all connection can be created automatically between these nodes. To enable the automatic copy-all connection, take the following steps:
1.Go to the Connection menu.
2.Click Settings for Connect Matching Children.
3.Check the box Create copy-all connections and click OK.
4.Press the toolbar button Toggle auto connect of children. Alternatively, go to the Connection menu and click Auto Connect matching Children.
If the structure of the nodes in the source and target files is not the same, the copy-all connection will not be created automatically, and you will need to create it manually.
To create a copy-all connection manually, take the following steps:
1.Add a source file: Click XML Schema/File in the Insert menu and browse for books.xml located in <Documents>\Altova\MapForce2022\MapForceExamples\Tutorial\.
2.Add a target file: Click XML Schema/File in the Insert menu and browse for library.xsd located in the same folder as books.xml. Click Skip when MapForce suggests adding an XML sample file.
3.Map the <book> node of the books component to the <publication> node of the library component. As the structure of the <book> and <publication> elements does not fully coincide, the copy-all connection is not created. Instead, the Auto Connect Matching Children function automatically connects all the child elements with the same name, which is discussed in Tutorial 1.
4.To change the automatic connection to a copy-all connection, right-click the connection between <book> and <publication> and select Copy-All (Copy Child Items) from the context menu.
5.A pop-up window will appear and suggest replacing the existing connections with a copy-all connection. Click OK. Now the source and target have a copy-all connection (see screenshot below).
In the mapping above, only two child items are identical in the two structures: <author> and <title>. Therefore, they are mapped from the source to the target. When a copy-all connection is created, the child elements that are not the same cannot be connected. The id item is not included in the copy-all connection, because its type is not the same in the source and target: id is an attribute in the source and an element in the target. If you attempt to create a connection between items that are not the same, e.g., <category> and <genre>, MapForce prompts you to replace it or duplicate the input (see screenshot below).
Duplicating input only makes sense if you want the target to accept data from more than one input, which is not required here (see Duplicating Input). If you choose to replace the copy-all connection, a message box prompts you again to resolve or delete the copy-all connection (see screenshot below).
Click Resolve copy-all connection if you want to replace the copy-all connection with individual target-driven connections to the corresponding child items. If you prefer to remove the copy-all connection completely, click Delete child connections.
•When you create a copy-all connection 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.