user3407479
user3407479

Reputation: 287

Is this aggregation possible in the Mule ESB DataMapper

Is this aggregation possible in the Mule ESB DataMapper

I have the following structures:

Strcuture A:

<item>
  <id>123</id>
  <price>1</price>
</item>
<item>
  <id>124</id>
  <price>2</price>
</item>
<item>
  <id>125</id>
  <price>3</price>
</item>

Structure B:

<total>
  <totalPrice>6</totalPrice>
</total>

If I want a sumation of all the fields in structure A to be placed into the totalprice of structure B, would taht be possible in the DataMapper.

If it is possible, how would you do it?

Thanks

Upvotes: 0

Views: 61

Answers (1)

V&#237;ctor Romero
V&#237;ctor Romero

Reputation: 5115

The source XML you show is invalid, you can only have one root element to have a valid XML. So I guess you have a <items> root element.

You could say, from prices generate total, and then create an xpath rule with sum(//price) and then map it to total.

Upvotes: 1

Related Questions