简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM