Repeating Nodes Due to the Destination Structure
The destination structure controls the number of repetitions of nodes. The repetitions are controlled by the destination node attributes Path and Is relative path.
Note: See also section Self Calculated Number of Node Repetitions.
Node Attribute Path
The following screenshot shows the effects of the node attribute Path using two examples.
(1) Source structure. The destination structure refers to this structure.
(2) Destination structure. Controls the creation of the destination tree.
(3) The node attribute Path has been set to the source structure node of the same name (OrderHeader). The names of the nodes are freely assignable and do not have to be identical. However, the path value must be a node name from the source structure.
(4) As an alternative to (3), the path of the node has been set to Position. Of course, only one path can be specified.
(5) The source tree created from the source structure (1).
(6) The destination tree created from the source tree using the destination structure and (3). Since the assigned node in the source tree occurs only once, the node in the destination tree is also created only once.
(7) The destination tree created from the source tree using the destination structure and (4). The assigned node in the source tree (Position) occurs several times, in the destination tree the node is repeated just as often.
Node Attribute Is relative path
As mentioned earlier, the node attribute Path works in conjunction with the node attribute Is relative path, which determines from which direction (top or bottom) the occurrences of the assigned path are counted. Depending on the value of this node attribute, different numbers of occurrences of the assigned node are found.
The illustrations below contain examples for clarification. Since the previous examples are not complex enough to show the possibilities of the mapper, an additional level of complexity has been added in the following examples.
The following screenshot shows the source and destination structure for the following examples.
(1) Source structure. An order position consists of one position and any number of texts for this position.
(2) Destination structure. OrderHeader and OrderPosition are mapped as before with a relative path to the nodes of the same name in the source structure. The mapping of Position and PositionText will be changed in the following examples and the effects will be shown there.
(3) Mapping from OrderHeader to OrderHeader with a relative path (1:1 mapping).
(4) Mapping from OrderPosition to OrderPosition with a relative path (1:1 mapping).
The following figure shows the result of the mapping if the node property Is relative path has the value No (i.e. the absolute path is used).
(1) Mapping of Position and PositionText with a path to the respective source structure node with the same name and Is relative path with the value No.
(2) Source tree. For clarity, the fields are not displayed.
(3) Destination tree. For clarity, the fields are not displayed.
(4) The node Position is repeated as often as the node occurs in the source tree (controlled by the path). The algorithm looks for all nodes named Position in the source tree and finds two occurrences. Therefore, the node in the destination tree is also repeated twice.
(5) The node PositionText is repeated as often as the node occurs in the source tree (controlled by the path). The algorithm looks for all nodes named PositionText in the source tree and finds four occurrences. Therefore, the node in the destination tree is also repeated four times.
You can imagine the destination nodes as a program loop. These nodes are simply repeated as many times as the corresponding source nodes are found. The number of occurrences depends on the node attribute Is relative path, as shown in the following figure.
(1) Mapping of Position and PositionText text with a path value PositionText and node attribute Is relative path with the value Yes.
(2) Source tree. For clarity, the fields are not displayed.
(3) Destination tree. For clarity, the fields are not displayed.
(4) The node Position is repeated as often as the node PositionText in the source tree under the parent node (OrderPosition) (controlled by the path). The algorithm looks for all nodes named PositionText under the parent and finds one occurrence. Therefore, the node in the destination tree is also repeated once.
(5) The node Position is repeated as often as the node PositionText in the source tree under the parent node (OrderPosition) (controlled by the path). The algorithm looks for all nodes named PositionText under the parent and finds three occurrences. Therefore, the node in the destination tree is also repeated three times.
For a relative path (attribute Is relative path with value Yes), the algorithm searches like this.
Search for nodes with the same name in the source tree below (and including) the parent node. If nodes are found, count them and repeat the node on the destination side as many times. If nothing is found, execute the next step.
Go up one level and look for nodes with the same name below (and including) the parent node. If nodes are found, count them and repeat the node on the destination side as many times. If nothing is found, repeat the step until you find something or until the root of the record is reached.
The following figure shows the algorithm based on a schematic destination tree.
(1) The starting point of the search. Within the marked area, the occurrence of the specified node (path) is searched for.
(2) If nothing is found in (1), the algorithm expands its search range one node up and looks below the new starting point for all occurrences of the specified node (path).
(3) If nothing is found in (2), the algorithm expands its search range one node up and looks below the new starting point for all occurrences of the specified node (path).
(4) If nothing is found in (3), the algorithm expands its search range one node up and looks below the new starting point for all occurrences of the specified node (path). The marked area here corresponds to the absolute path setting since all occurrences of the node are found. The search is not extended beyond the limits of the record.
Node Attribute Optimize path
If attribute Optimize path has value No, the usually active path optimisation will be deactivated. If a child node in the destination structure has the same path as its parent node and its attribute Is relative path has value No, this node will only appear once in the destination tree if the optimisation is enabled. If the optimisation is disabled, the node appears in the destination structure as often as it appears in the source tree.