# Step 7: Looping Through Items in a List

In this step, you create the logic to extract a list of items from the Request for Quote document received from a client, and begin the work of designing the business process to determine the price and availability of the items requested by the client.

A For Each node represents a point in a business process where a set of activities is performed repeatedly, once for each item in a list. A For Each node includes an iterator node (on which a list of items is specified) and a loop (in which the activities to be performed for each item in the list are defined). An iteration variable holds the current element being processed in the For Each loop, for the life of the loop.

This section includes the following topics:

- Understanding XML Schemas and For Each Nodes
- Design a For Each Loop in Your Business Process

## Understanding XML Schemas and For Each Nodes

The business process you build in this tutorial is designed to start when it receives a Request for Quote XML document from a client. The Request for Quote document must contain valid XML, that is, XML valid against an XML Schema, specifically QuoteRequest.xsd. The QuoteRequest.xsd Schema is located in your application at the following location: myapplications\Tutorial_Process_Application\Tutorial_Process_ApplicationWeb\Schemas.

In the preceding line, myapplications represents the location of your tutorial application.

Note: To make the Schemas in your project available in your business process, you must place them in a Schemas project. A Schemas project is one of the types of projects that Workshop applications can contain. The Schemas projects added to your WebLogic Workshop applications are represented in the WebLogic Workshop file hierarchy as child folders of your application folder. To learn about creating and populating Schemas projects in your WebLogic Integration applications, see Related Topics.

XML Schemas in your application's Schemas folder are compiled to generate XML Beans. In this way, WebLogic Workshop generates a set of interfaces that represent different aspects of your XML Schemas. XML Bean types correspond to types in the XML Schema itself. XML Beans provides Java counterparts for all built-in Schema types, and generates Java counterparts for any derived types in your Schema.

In Step 2: Specify How the Process is Started, you created a variable (requestXML) to which the Request for Quote document (which your business process receives from a client) is assigned. When you work with such variables in the Design View, you work with a graphical representation of the XML Schema that is associated with the variable. The following figure is a graphical representation of the quoteRequest element in the QuoteRequest.xsd schema, against which the Request for Quote document from clients is valid:

Note the following characteristics of the QuoteRequest.xsd Schema:

- The elements and attributes of the XML schema are represented as nodes. Note that quoteRequest is a root element.
- The quoteRequest element specifies the following child elements: customerName, shipAddress, and widgetRequest.
- The shipAddress element specifies the following attributes: street, city, state, and zip.
- The widgetRequest element is a repeating element (represented graphically by ). In other words, there can be one or more occurrences of the widgetRequest element in an associated XML document. The widgetRequest element, in turn, contains two elements: widgetId and quantity.

The business process in this scenario dictates that each pair of widgetId and quantity elements received in the Request for Quote documents from clients is processed. This processing begins with a For Each node—each iteration through the For Each loop processes one of a set of widgetRequest items.

In this section, you design the For Each node to first extract a list of items (the widgetRequest items) from the requestXML variable, and then to perform an activity (or set of activities) repeatedly, once for each item in the list.

Related Topics

How Do I: Create a Schemas Project Folder?

How Do I: Import Files into a Schemas Project Folder?