问题
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
回答1:
Use a rule, like described in a your previous question, but use the following xpath: sum(//price[../type='BBB'])
.
来源:https://stackoverflow.com/questions/27988341/mule-esb-datamapper-aggregation-of-field-conditional-to-field-type