[ repeat icon ]


Iterators enables the direct expression of the repeated application of the same process body. It specifies the control flow so that the output of the previous instance of the process can be the input of the next one.


The iterator is not an abstract process but rather a constructor of the Transmorpher language. It cannot be refined. The iterator can take several input and output channels and a channels attribute which allows users to specify the data flow within the iterator: output is copied to the channels channels so that it can be compared with the next output.

The repeat element introduces the use of an iteration in a process body. Its structure is the following:

<repeat id="id" in="channels" test="channels" out="channels"> {<with-param>}* {<iterator>}* process-body </repeat>

The bibliography example does not use iterators, so here is a simple example.

<process name='myotherprocess' in='channel1,channel2' out='channel3'> <repeat in='channel1' channels='channel4' out='channel3'> <apply-process id='p1' name='myprocess' in='channel4' out='channel4'> </repeat> </process>

Saturation (or closure)


The iterators allows a variable to be iterated over a particular domain. Each domain has a particular way to be iterated and hence a particular iterator.

XML declaration

The iterator element introduces the use of a variable which will be iterated over a particular structure. It must contain a name, a type and other type-specific parameters that will specify its behavior.

<iterator name="name" type="name"> {<with-param>}* </iterator>

For instance,

<repeat id="rep" in="i" out="o"> <iterator type="int" name="j"> <with-param name="from">7</with-param> <with-param name="incr">-1</with-param> <with-param name="to">0</with-param> </iterator> process-body </repeat> repeats 8 times the process body.

Built-in iterators

Transmorpher provides several built-in iterators:

always iterate. The variable value is set to "".
iterates over integers. It accepts the from, to, incr parameters.
directoryIterator (?)
iterates over the filenames in a directory. Requires the path parameter.
iterates over the filenames in a directory. Requires the dir parameter and accepts other parameters such as recursive, sort, filter.

References to contributed iterators can be found here

Manipulation API

Extension API

Iterators implements the fr.fluxmedia.transmorpher.TProcessFactory.TIterator interface which extends Enumeration. They must provide the implementations of methods init(Parameters), hasMoreElements() and nextElement().

Iterated flows

Because, the iterators runs the same process several times, it is necessary to know what happens with the flows in the channels. The channels within an iterator are special channels (called feedback) which allows the output to be reused as input. For instance,

<repeat id="rep" in="i" out="o"> <apply-external type="int" in="i" out="o"/> </repeat> specifies that there is only one feedback.

The repeat processing is thus the following:

MMerge and MDispatch

MMerge and MDispatch obey the same behavior as that of mergers and dispatchers. However, they differ on their position in Transmorpher: they are exclusively used at the interface between an iteration and the rest of the process. They have exactly one input and one output channels.

They enables input from an outer channel to feed each iteration and output from each iteration to feed an outer channel.

MMerge concatenates the output of each iteration on its output channel. MDispatch generates its complete input at each iteration.

NOTE: they have not been implemented yet. The idea is that they will behave exactly like merge and dispatch (and thus inherit all their defined types). They just have to fake the multiple in/output by each output iteration.

Next chapter: Queries

Feel free to comment to Jérôme:Euzenat#inrialpes:fr, $Id: iter.html,v 1.5 2005/10/25 13:34:00 euzenat Exp $