Designing For Each Nodes

Before you can add the logic that causes the iteration over a sequence of XML nodes in your business process, your project must contain an XML Schema or MFL file that defines the repeating XML or MFL element over which you want your business process to iterate. To learn how to import an XML Schema or MFL file into your project, see Importing Files into the Schemas Project.

After importing an XML Schema or MFL file into your project, you can complete the design of the For Each node. It includes the following tasks:

To Select a Repeating XML or MFL Element Over Which to Iterate

The For Each node only iterates over repeating elements. The node builder allows you to select a repeating node from the variable you created in the preceding section.

  1. In the Design View, double-click the For Each node to invoke its node builder.
  2. Click Select Variable to select a variable that you have already created in your project or create a new variable to use in your decision node:
    1. If you want to use a variable that is already created, select the variable that contains the XML or typed non-XML on which you want to build the condition.
    2. For example, if we import an XML Schema (QuoteRequest.xsd) into our project, and create a business process variable (requestXML) of type quoteRequest (based on the QuoteRequest.xsd schema), the requestXML variable is available in the drop-down list of business process variables:

      image

      Note: To learn about creating business process variables and importing schemas to your project, see Business Process Variables and Data Types and Importing Files into the Schemas Project.

      Go to step 3.

    3. If you want to create a new variable, select Create new variable... from the drop-down list.
    4. The Create Variable dialog box opens.

    5. Enter a name for your new variable in the Variable Name field.
    6. Select the XML or nonXML option, depending on if your variable is based on a XML document or MFL file and select the appropriate variable type in the displayed list of type options.
    7. Click OK.
    8. The Create Variable dialog box closes and your new variable is displayed in the Select Node pane.

  3. Continuing with our example, a representation of the XML in the requestXML variable is displayed in the Select Node panel.
  4. image

    Note the following characteristics of the QuoteRequest.xsd schema as displayed in the preceding figure:

  5. Select a repeating element in the Select Node field.
  6. The Repeating Element and Iteration Variable fields are populated with data:

  7. Click the X in the top right-hand corner to close the node builder and return to the Design View.
  8. In the Design View, note that the icon in your For Each node displays the following graphics:

  9. To save your work, select File —> Save.

To Add Activities to the For Each Node

You must define the activity or set of activities that are performed for each item in the list you created in the preceding step (To Select a Repeating XML or MFL Element Over Which to Iterate). Each iteration of the For Each loop executes the activity or activities you specify in a node (or nodes) in the loop.

  1. In the Palette, click a node that represents the logic you want to add to the business process.
  2. Drag and drop the node from the Palette onto the business process in the Design View, placing it on the business process within the For Each loop.
  3. As you drag a node onto the For Each loop, a target image appears on the loop, representing a valid location in the For Each loop where you can place the node. As you drag the node near the valid location, the target is activated image and the cursor changes to an arrow image . You can release the mouse button and the node snaps to the For Each loop.

  4. On the node (or nodes) you add to the For Each loop, create the activities appropriate for your business process's business logic.

To learn about designing For Each loops and how data is assigned to variables within the loops, see Looping Through Items in a List in Tutorial: Building Your First Business Process.

Related Topics

Creating Looping Logic

Grouping Nodes in Your Business Process

Handling Exceptions

Adding Message Paths

Adding Timeout Paths

Previous Document Next Document