Copy-all connections map data between nodes with child nodes that are similar or the same. Copy-all connections are possible only 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. See Mapping: Sources and Targets to find out more about the formats that can be used as data sources and targets.
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 example in Create Copy-all Connections Manually). The subsections below explain how to create copy-all connections automatically and manually.
Create copy-all connections automatically
To create a copy-all connection automatically, 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 types and/or names of child nodes in the source and target are not the same, a copy-all connection will not be created automatically, and you will need to create it manually.
Create copy-all connections 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 the BasicTutorials folder.
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 structures of the <book> and <publication> elements do not fully coincide, the copy-all connection is not created. Instead, the Auto Connect Matching Children function automatically connects all the child nodes 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 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 nodes are identical in the two structures: <author> and <title>. Therefore, a copy-all connection exists between these nodes. Child nodes that are not the same cannot be connected. The screenshot shows that id 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 try to create a connection between nodes that are not the same, e.g., <category> and <genre>, MapForce prompts you to replace this connection or duplicate the input.
Duplicating input only makes sense if you want the target to accept data from more than one input, which is not required here. If you choose to replace the copy-all connection, a message box prompts you again to resolve or delete the copy-all connection. Click Resolve copy-all connection if you want to replace the copy-all connection with individual target-driven connections. 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.