ForEach Mediator
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

ForEach Mediator

The ForEach mediator requires an XPath expression and a sequence (inline or referred). It splits the message into a number of different messages derived from the original message by finding matching elements for the XPath expression specified. Based on the matching elements, new messages are created for each iteration and processed sequentially. The processing is carried out based on a specified sequence. The behaviour of ForEach mediator is similar to a generic loop. After mediation, the sub-messages are merged back to their original parent element in the original message sequentially.

The ForEach mediator creates the following properties during mediation.

Property

Description

Property

Description

FOREACH_ORIGINAL_MESSAGE

This contains the original envelop of the messages split by the ForEach mediator.

FOREACH_COUNTER

This contains the count of the messages processed. The message count increases during each iteration.



Syntax

<foreach expression="xpath" [sequence="sequence_ref"] [id="foreach_id"] > <sequence> (mediator)+ </sequence>? </foreach>

Configuration

The parameters available to configure the ForEach mediator are as follows.

Parameter Name

Description

Parameter Name

Description

ForEach ID

If a value is entered for this parameter, it will be used as the prefix for the FOREACH_ORIGINAL_MESSAGE and FOREACH_COUNTER properties created during mediation. This is an optional parameter. However, it is recommended to define a ForEach ID in nested ForEach scenarios to avoid the properties mentioned from being overwritten.

Expression

The XPath expression with which different messages are derived by splitting the parent message. This expression should have matching elements based on which the splitting is carried out.

You can click NameSpaces to add namespaces when you are providing an expression. Then the Namespace Editor panel would appear where you can provide any number of namespace prefixes and URLs used in the XPath expression. 

Sequence

The mediation sequence that should be applied to the messages derived from the parent message. ForEach mediator is used only for transformations, thereby, you should not include Call Send  and Callout mediators, which are used to invoke endpoints, in t his sequence.

You can select one of the following options.

  • Anonymous: This allows you to define an anonymous sequence to be applied to the split messages by adding the required mediators as children of the ForEach mediator in the mediator tree.

  • Pick from Registry: This allows you to pick an existing mediation sequence that is saved in the Registry. Click either Configuration Registry or Governance Registry as relevant to select the required mediation sequence from the Resource Tree.




Examples

In this configuration, the //m0:getQuote/m0:request" XPath expression evaluates the split messages to be derived from the parent message. Then the split messages pass through a sequence which includes a Log mediator with the log level set to full.



Sample

See Sample 18: Transforming a Message Using ForEach Mediator.



com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.