Please enable JavaScript to view this site.

Altova MapForce 2020 Professional Edition

The group-ending-with function takes a Boolean condition as argument. If the Boolean condition is true, a new group is created, ending with the record that satisfies the condition. In the example below, the condition is that "Key" must be equal to "trailing". This condition is true for the third and fifth records, so two groups are created as a result:

mf_group-ending-with

Note:One additional group is created if records exist after the last one that satisfies the condition. For example, if there were more "line" records after the last "trailing" record, these would all be placed into a new group.

 

Arguments

Name

Type

Description

nodes/rows

A sequence of items

A sequence of nodes or rows (for example, the connection may originate from a source XML node with child items, a CSV record, and so on).

bool

xs:boolean

Specifies the Boolean condition that starts a new group when true.

 

Example

Let's assume that your source data is an XML file with the following content (note that, in the code listing below, the namespace and XML declarations were removed for simplicity).

 

<records>
  <record key="line" value="A"/>
  <record key="line" value="B"/>
  <record key="trailing" value="Total 1"/>
  <record key="line" value="C"/>
  <record key="trailing" value="Total 2"/>
</records>

 

The business requirement is to create groups for each "trailing" record. Each group must also include any "line" records that precede the "trailing" record. To achieve this, the following mapping invokes the group-ending-with function. In the mapping below, whenever the key name is equal to "trailing", the argument supplied to bool becomes true, and a new group is created.

mf_group-ending-with_map

The mapping result is as follows:

 

<groups>
  <group>
    <record key="line" value="A"/>
    <record key="line" value="B"/>
    <record key="trailing" value="Total 1"/>
  </group>
  <group>
    <record key="line" value="C"/>
    <record key="trailing" value="Total 2"/>
  </group>
</groups>

 

This example, together with other grouping examples, is part of the following mapping file: <Documents>\Altova\MapForce2020\MapForceExamples\Tutorial\GroupingFunctions.mfd. Remember to click the Preview mf_ic_preview button applicable to the function you want to preview, before clicking the Output tab.

© 2019 Altova GmbH