Merging Two Corresponding Lists
You may need to merge two lists that have corresponding items into one repeating element.
For example, you may have a list of student IDs and a list of grades, each grade corresponds to the student ID in the same position in the student ID list.
- Procedure
- Map the first repeating element from the Scope Variables area into the Grades repeating element in the Function panel. In this example, the
$RetrieveStudentIDs/Students/Record
is the first repeating element. - Drag the second repeating element into the For-Each statement.
- The Mapping Wizard dialog appears asking you to choose an option. Choose the Merge parallel repeating structure option and click Next.
- Merging two parallel repeating structures requires two variables. The mapping wizard prompts you to name these two variables. One variable is to hold the position number of the current item being processed, and the other variable is to hold the item in the second list that corresponds to the position of the item in the first list. Create the variables with the default names supplied by the mapping wizard, or choose your own names for these variables. Click
Finish to proceed.
The two variables appear in the Scope Variables area once you have completed this step. The two variables also appear in the Function panel with the correct XPath statement to produce the desired result.
The
$=[index=]
element contains the XPath formulaposition()
to set the element with the current position number of the list item being processed. The$=[item=]
element contains a statement to retrieve the item in the second repeating element that corresponds to the position of the item in the first list that is currently being processed. - Map the
ID
element to theStudentID
element in the function arguments. - Map the
$=item/Grade
element to theGrade
element in the Function panel.