Available Iterators

In this section:

 

The following sections describe available Iterator Object properties and provides an example for each iterator type.


Top of page

x
Attachment Iterator {com.ibi.agents.XDIterAttachments}

Property Name

Allowable Value

Description



Example: Attachment Iterator


Top of page

x
Chunk Iterator {com.ibi.agents.XDIterChunk}

Property Name

Allowable Value

Description

Chunk Size

The size of the chunk, the number of octets to pass from the input stream.

success

A chunk is being passed

fail_parse

The configuration could not be processed. This is caused by an iFL error returning a non-numeric value.



Example: Chunk Iterator

The com.ibi.agents.XDIterChunk iterator reads the input stream in the input document and breaks it into chunks of a specified size. The input stream may come from one of the streaming components, for example, a file listener set for streaming, or a file read agent configured with stream format. The chunk is passed as a flat document containing bytes, which can be manipulated within the flow.

Process Flow Diagram


Top of page

x
Condition Iterator {com.ibi.agents.XDIterCond}

Property Name

Allowable Value

Description



Example: Condition Iterator

Top of page

x
Counter Iterator {com.ibi.agents.XDIterCount}

Property Name

Allowable Value

Description

Iterations

A numeric expression, constant, XPath, or variable.

Number of times this iterator loop is to be repeated.

Interim document type

A literal, variable, or XPath that evaluates to "original" or "transient."

Determines whether the document passed out of the Iterator object into the loop is the original or the result of the previous iteration (transient).

Output document type

A literal, variable, or XPath that evaluates to "original" or "transient", or "status."

Determines whether the document passed out of the Iterator object upon completion of the loop is the original or the result of the previous iteration (transient).



Example: Counter Iterator

The com.ibi.agents.XDIterCount operator repeats the body of the loop a specified number of times. The number can be constant or computed at run time, for instance, with an XPath expression, as in this example. The inner part of the loop can be used to generate multiple outputs, read multiple inputs from a source, or perform any other operation repeatedly. The count iterator can also be used with conditional logic to add retry functionality to an adapter that does not natively support retry. The number of iterations of the loop is not dependent on the structure of the input document, nor does the count iterator parse the document before injecting it into the loop.

The Iterator object in this example passes the input document into the loop the number of times specified by the <count> XML tag in the input document. The following sections show the process flow, the Iterator object parameters, and the input and output documents of this example.

Process Flow Diagram

Iterator Object Parameters

Input Document

<IterCountTest>
   <count>3</count>
</IterCountTest>

Output Document(s)

Three documents are output by the FileWrite object: IterCount01.xml, IterCount02.xml, and IterCount03.xml.

<?xml version="1.0" encoding="UTF-16"?>
<IterCountTest>
   <count>3</count>
</IterCountTest>

Top of page

x
FTP Iterator {com.ibi.agents.XDIterFTPEmitStdAgent}

Property Name

Allowable Value

Description



Example: FTP Iterator

Top of page

x
Island Iterator {com.ibi.agents.XDIterIsland}

Property Name

Allowable Value

Description

Island identifier

A string expression, constant, XPath, or variable.

Name of the XML tag that identifies the Island command string.

Remove Identifier

A Boolean literal, variable, or XPath.

Determines whether the Island tag and text will be removed or preserved in the final document.



Example: Island Iterator

The {com.ibi.agents.XDIterIsland} iterator is designed to perform document enhancement, that is, to replace parts of the input XML document with the results of a call to an agent or adapter. Any external data source can be targeted (Web Services, SQL data, and so on), but in this example embedded file names are replaced with the content of the named disk file. The replacement would behave identical regardless of the source, although the replacement data must be in XML format. Island replacement is iterated for as many tags as are present in the input document. The tags to be replaced may be homogeneous, as in this example, or heterogeneous by using multiple sequential Island iterators targeting different sources.

The following sections show the process flow, the Iterator object parameters, and the input and output documents of this example.

Process Flow Diagram

Iterator Parameters

Input Document

The primary input document is the document that contains the Islands to be replaced. In this example, they are identified by the XML tag <file>.

<mydoc>
   <file>file1.txt</file>
   <file>file2.txt</file>
   <file>file3.txt</file>
</mydoc>

file1.txt

<content>Contents of file 1</content>

file2.txt

<content>
<line>Contents of file 2</line>
<line>There are 2 lines</line>
</content>

file3.txt

<content>Contents of file 3</content>

Output Document(s)

The input document and the island documents are combined according to the behavior of the iterator.

<?xml version="1.0" encoding="UTF-8" ?>
<mydoc>
   <content>Contents of file 1</content>
   <content>
      <line>Contents of file 2</line>
      <line>There are 2 lines</line>
   </content>
   <content>Contents of file 3</content>
</mydoc>

Top of page

x
Iter RVI Iterator {com.ibi.agents.XDIterRVIRelay}

Property Name

Allowable Value

Description



Example: Iter RVI Iterator

Top of page

x
Line Iterator {com.ibi.agents.XDIterLine}

Property Name

Allowable Value

Description

Keep blanks

A literal (true/false), variable or XPath expression that evaluates to a Boolean result.

Determines whether blank lines will be passed into the loop for processing.

Output

A literal, variable, or XPath that evaluates to "original" or "status".

Determines whether the document passed out of the Iterator object upon completion of the loop is the original unparsed document or the result status.



Example: Line Iterator Type

The {com.ibi.agents.XDIterLine} operator repeats the body of the loop once for each line in the document, as defined by standard end-of-line delimiters. The inner part of the loop can be used to generate multiple outputs, read multiple inputs from a source, or perform any other operation repeatedly. When using this iterator, the number of times through the loop and how the input is parsed is directly related to the structure of the input document, in particular, how many lines are present. We recommend that non-XML, line-oriented input be read into the process flow with a File object rather than being passed through the Start node.

The following sections show the process flow, the Iterator object parameters, and the input and output documents of this example.

Process Flow Diagram

Iterator Object Parameters

Input Document

This is the first line
This is line 2
Line 3

Output Document(s)

Three documents are output: IterLine01.txt, IterLine02.txt, and IterLine03.txt.

This is the first line
This is line 2
Line 3

Top of page

x
SQL Batch Iterator {com.ibi.agents.XDIterSQLBatchAdd}

Property Name

Allowable Value

Description



Example: SQL Batch Iterator

Top of page

x
SQL Select Iterator {com.ibi.agents.XDItSQLSelect}

Property Name

Allowable Value

Description



Example: SQL Select Iterator

Top of page

x
Sibling Iterator {com.ibi.agents.XDIterSibSplit}

Property Name

Allowable Value

Description

Output document type

A literal, variable, or XPath that evaluates to "original" or "status."

Determines whether the document passed out of the Iterator object upon completion of the loop is the original or the result status. By definition, the Interim document type is always the next sibling (that is, transient), never the original.



Example: Sibling Iterator

The {com.ibi.agents.XDIterSibSplit} construct is used to contain the output of multi-row SQL queries. By bundling sets of rows, siblings makes the handling of very large result sets more practical. When used with the IterSibSplit operator, the logic inside the loop is executed once for each sibling document. One result row per sibling document is recommended for this iterator. Because the entire answer set is fetched prior to executing the loop, flows using this technique may have high memory requirements.

The following sections show the process flow, the Iterator object parameters, and the input and output documents of this example.

Process Flow Diagram

Iterator Object Parameters

In this case, the Iterator object parameters are not material, and the parameters of the SQL object that generates the internal document are significant. Note that the properties are set to produce siblings (which are internal, non-XML iWay constructs), with one SQL row for each sibling.


Top of page

x
Test Iterator {com.ibi.agents.XDIterTest}

Property Name

Allowable Value

Description

Operand One

A literal, variable, or XPath that evaluates to a value.

The first of two operands to compare.

Operation

The comparison to apply to the two operands, or a null test predicate on Operand One.

Used to compare Operand One and Operand Two, producing a Boolean result.

Operand Two

A literal, variable, or XPath that evaluates to a value.

The second of two operands to compare. In the case of a null/not null test, this parameter is optional.

Iterate Rule

A literal (true/false), variable, or XPath expression that evaluates to a Boolean result.

Used to invert the logic of the Iteration test from do‑while to do-until. Using a non‑constant expression can simplify the flow logic by reversing the sense of the test dynamically.

Interim document type

A literal, variable, or XPath that evaluates to "original" or "transient."

Determines whether the document passed out of the Iterator object into the loop is the original or the result of the previous iteration (transient).

Output document type

A literal, variable, or XPath that evaluates to "original" or "transient", or "status."

Determines whether the document passed out of the Iterator object upon completion of the loop is the original or the result of the previous iteration (transient).



Example: Test Iterator

The {com.ibi.agents.XDIterTest} operator repeats the body of the loop while a specified logical comparison evaluates to True. The predicate is reevaluated each time through the loop. The inner part of the loop can be used to generate multiple outputs, read input multiple times from a source, or perform any other operation repeatedly. Similar to the count iterator, the test iterator can be used to retry an operation until it is successful or other criteria are met.

The following sections show the process flow, the Iterator object parameters, and the input and output documents of this example.

Process Flow Diagram


Top of page

x
XML SPLIT Iterator {com.ibi.agents.XDIterXMLSplit}

Property Name

Allowable Value

Description

Snip Levels

A literal, variable, or XPath that evaluates to an integer that is zero or greater.

Determines how many tag levels to trim off of the new XML document, starting from the top (root) node.

Zero equals preserve all levels, one equals cut off the root, two equals cut off the root and immediate child, and so on, down to the XPath location being iterated. The default is zero, which will return all parent tags up to the root.

Note: Cross Section data may be lost depending on the snip level setting.

Expression

An XPath string, derived from a constant, XPath, or variable.

An XPath that indicated where in the document to begin processing.

Cross Section

A literal, variable, or XPath that evaluates to true or false.

When set to false, only the direct parent tags of the iterated section are present in the split document.

When set to true, all sibling sub‑trees of parent tags are preserved.

Output document type

A literal, variable, or XPath that evaluates to "original" or "status."

Determines whether the document passed out of the Iterator object upon completion of the loop is the original, or the result status. By definition, the Interim document type is always the split document (that is, transient), never the original.

When you are finished entering the properties, click Finish. The Iterator object appears in the workspace.

The following examples show an implementation of each iterator type.



Example: XML SPLIT Iterator

Often, a single transaction document contains repeating groups of data, in this example, a simplified invoice with multiple line items. The {com.ibi.agents.XDIterXMLSplit} iterator extracts the repeating group specified by the XPath expression. The parsed document contains the indicated group and preserves its direct parental lineage of XML nodes. If the logic inside your loop needs data from a parallel XML path (the invoice number in this example), then you can set Cross Section to true. Cross Section will preserve the entire document above the node that is the target of Expression.

The body of the loop is repeated once for each occurrence of the indicated group. The inner part of the loop can be used to process the repeating groups, call a Web service, insert the data into an SQL database, and so on. When using this iterator, the number of times through the loop and how the input is parsed depends on the structure of the input document and the XPath expression.

The following sections show the process flow, the Iterator object parameters, and the input and output documents of this example.

Process Flow Diagram

Iterator Object Parameters

Input Document

<invoice>
   <invoice-number>1001</invoice-number>
   <line-item>
      <item-number>1</item-number>
      <item-desc>Red Widget</item-desc>
   </line-item>
   <line-item>
      <item-number>2</item-number>
      <item-desc>Blue Widget</item-desc>
   </line-item>
   <line-item>
      <item-number>3</item-number>
      <item-desc>Green Do-dad</item-desc>
   </line-item>
</invoice>

Output Document(s)

Three documents are output by the FileWrite object: IterXmlSplit01.xml, IterXmlSplit02.xml, and IterXmlSplit03.xml.

<?xml version="1.0" encoding="UTF-16" ?>
<invoice>
   <line-item>
      <item-number>1</item-number>
      <item-desc>Red Widget</item-desc>
   </line-item>
</invoice>
<?xml version="1.0" encoding="UTF-16" ?>
<invoice>
   <line-item>
      <item-number>2</item-number>
      <item-desc>Blue Widget</item-desc>
   </line-item>
</invoice>
<?xml version="1.0" encoding="UTF-16" ?>
<invoice>
   <line-item>
      <item-number>3</item-number>
      <item-desc>Green Do-dad</item-desc>
   </line-item>
</invoice>

The following is an output document with Cross Section set to true.

<?xml version=”1.0” encoding=”UTF-16” ?>
<invoice>
   <invoice-number>1001</invoice-number>
   <line-item>
      <item-number>1</item-number>
      <item-desc>Red Widget</item-desc>
   </line-item>
</invoice>

The following is an output document with Snips Level set to 1.

<?xml> version=”1.0” encoding=”UTF-16” ?>
<line-item>
   <item-number>1</item-number>
   <item-desc>Red Widget</item-desc>
</line-item


iWay Software