Filter Recurring Nodes
By specifying an XPath predicate to filter against during run time, you can limit the recurring nodes returned by a mapping activity.
About this task
- A While Loop or For Each activity that loops through the recurring structures
- An If...Then activity to test for values.
For example, you can limit the
books processed by the BatchOrderProcessingSample orchestration
to only return book titles that start with the letter B using either
of the following methods:
- After the Read Flat File activity which converts flat file data to XML, you can add a While Loop activity that contains an If..Then activity that tests for all book titles that start with the letter B. When the While Loop activity completes at run time, it returns the set of recurring BookOrder nodes that have titles beginning with the letter B.
- Filter by specifying a predicate directly in the To Orchestration pane of the Map Outputs task of the Read Flat File activity that converts flat file data to XML. This is the preferred method because it reduces the processing during run time - improving orchestration performance. For example, you can specify the following predicate on the recurring BookOrder node to limit the Bookorder nodes returned during run time to only those titles that begin with the letter B:*:title/starts-with(.,'B')
Predicate Characters | Description |
---|---|
*: | Specifies this predicate applies to any namespace of the source node. |
title/ | Specifies to apply this predicate against the title node of the current source node. |
starts-with(.,'B') | Specifies this predicate returns only nodes that have title nodes that start with the letter B. The starts-with function is a built-in XPath function. |
For more information about the BookOrder sample, see the Getting Started Guide. If you accepted the defaults during the installation of Studio, you can find the reference implementation of the sample in the following directory:C:\Program Files\IBM\WebSphere App Connect Studio 3.X\Samples\BookOrder
To specify a predicate on a recurring node: