user3407479
user3407479

Reputation: 287

Mule ESB DataMapper: Aggregation of field conditional to field type

Mule ESB DataMapper: Aggregation of field conditional to field type

I have the following structures:

Strcuture A:

<itemlist>
  <item>
    <id>123</id>
    <price>1</price>
    <quantity>1</quantity>
    <type>AAA</type>
  </item>
  <item>
    <id>124</id>
    <price>2</price>
    <quantity>1</quantity>
    <type>BBB</type>
  </item>
  <item>
    <id>125</id>
    <price>3</price>
    <quantity>1</quantity>
    <type>BBB</type>
  </item>
<itemlist>

Structure B:

<totals>
  <total>
    <totalPrice>3</totalPrice>
  </total>
</totals>

If I want a sumation of all the field, but only for structures with a of "BBB".

Can I do this in Mule ESB, and if so how would I do it?

Thanks

Upvotes: 0

Views: 51

Answers (1)

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

Reputation: 5115

Use a rule, like described in a your previous question, but use the following xpath: sum(//price[../type='BBB']).

Upvotes: 2

Related Questions