<webm:loop>
You use the <webm:loop> tag to execute a block of code once for each element in a specified Document, Document List, or String List in the Integration Server pipeline.
If you do not specify a Document, Document List, or String List to loop over, Integration Server will loop over the entire pipeline.
You can use the <webm:loopsep> tag to insert a specified character sequence between results from a <webm:loop> tag in the HTML page produced from the JSP. (<webm:loopsep> does not insert the character sequence after the result produced by the last iteration of the loop.)
At run time, Integration Server loops over the pipeline data as follows:
For this data structure... | Integration Server loops over… |
Pipeline | Each key in the pipeline. |
Document | Each key in the Document. |
Document List | Each Document in the Document List. |
String List | Each String in the String List. |
Syntax
For the pipeline:
<webm:loop loopStruct="true" [excludePrivate="true"]>
block_of_code
[<webm:loopsep sepString="separator_string"/>]
</webm:loop>
For a Document:
<webm:loop variable="loop_variable" loopStruct="true" [excludePrivate="true"]>
block_of_code
[<webm:loopsep sepString="separator_string"/>]
</webm:loop>
For a Document List or String List:
<webm:loop variable="loop_variable" [loopStruct="true"]>
block_of_code
[<webm:loopsep sepString="separator_string"/>]
</webm:loop>
Arguments
Argument | Description |
[variable="loop_variable"] | Document, Document List, or String List to loop over. If you do not specify this option, Integration Server loops over the entire pipeline. Example <webm:loop variable="items"> |
[loopStruct="true"] | Tells Integration Server to loop over each key in the pipeline, Document, Document List, or String List. Example <webm:loop variable="items" loopStruct="true"> If you want to dynamically access the names of the keys in the structure over which you are looping, use the predefined $key keyword. If you have nested loops and the outer loop is looping over a structure whose contents are dynamic, and you want the inner loop to loop over the keys in the current key of the outer loop, set variable in the inner loop to #$key keyword. You most often use this keyword to process a set of Documents contained within another Document. For an example of using these keywords, see the “Examples” section, below. |
[excludePrivate="true"] | Tells Integration Server to skip keys whose names begin with $. Example <webm:loop variable="items" excludePrivate="true"> |
Examples
This code puts shipping information for each Document in the Document List
items in the HTML page produced from the JSP.
<p>This shipment contains the following items:</p>
<webm:loop variable="items">
<p>
<webm:value variable="qty"/>
<webm:value variable="stockNum"/>
<webm:value variable="description"/>
<webm:value variable="status"/>
</p>
</webm:loop>
This code lists each element in the String List
backItems on separate lines in the HTML page and indicates that the elements are on backorder.
<p>The following items are backordered</p>
<p>
<webm:loop variable="backitems">
<webm:value/><BR>
</webm:loop>
</p>
This code lists the elements in the String List
backItems with commas between the elements and indicates that the elements are on backorder.
<p>The following items are backordered</p>
<p>
<webm:loop variable="backitems">
<webm:value/>
<webm:loopsep sepString=","/>
</webm:loop>
</p>
This code displays the names and values of the keys in the
Integration Server pipeline in the HTML page.
<webm:loop loopStruct="true">
<webm:value variable="$key"/><br>
<webm:value/><br>
</webm:loop>
This code loops over the keys in the Document named
Addresses, whose contents are not known until run time, and inserts each name and its associated address into the HTML page produced from the JSP. The basic structure of the Document looks like this:
Key | Value |
Global Sporting Goods, Inc. | Key | Value |
| streetAddr1 | 10211 Brookpark Road |
| streetAddr2 | |
| city | Cleveland |
| state | OH |
| postalCode | 22130 |
Fitness Shoes | Key | Value |
| streetAddr1 | 2549 Oak Avenue |
| streetAddr2 | |
| city | Silver Spring |
| state | MD |
| postalCode | 20905 |
.
.
.
Key | Value |
Yoga Wear | Key | Value |
| streetAddr1 | 6666 Maple Street |
| streetAddr2 | Suite 100 |
| city | New York |
| state | NY |
| postalCode | 11302 |
<p>Customer Addresses:</p>
<p>
<webm:loop variable="Addresses" loopStruct="true">
<webm:value variable="$key"/>
<webm:loop variable="#$key" loopStruct="true">
<webm:value variable="streetAddr1"/>
<webm:value variable="streetAddr2"/>
<webm:value variable="city"/>
<webm:value variable="state"/>
<webm:value variable="postalCode"/>
</webm:loop>
</webm:loop>
</p>