|
Home > Archive > BizTalk Server General > April 2005 > summing up repeating nodes in map
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
summing up repeating nodes in map
|
|
| Jeff Wessling 2005-04-21, 5:49 pm |
| This seems like it should be a fairly straightforward mapping task, but I'm
having trouble putting it together.
I have a file that has lineitems that have an ID, the ID may be repeated for
multiple lines. Each line also has an amount. How can I construct a map to
sum up all the amount for lines with the same ID.
Something like....
<item>
<id>0001</id><amount>100</amount>
</item>
<item>
<id>0001</id><amount>50</amount>
</item>
<item>
<id>0002</id><amount>100</amount>
</item>
<item>
<id>0002</id><amount>75</amount>
</item>
- to -
<record>
<id>0001</id><TotalAmount>150</amount>
</record>
<record>
<id>0002</id><TotalAmount>175</amount>
</record>
Any help would be most appreciated. Thanks!
| |
| Jeff Wessling 2005-04-28, 5:55 pm |
| I found that using an XPATH statement in an XSLT Call Template scripting
functoid did the trick for this nicely. I used something like
sum(//item[id=0001]/amount)
Viva XPATH!
"Jeff Wessling" <jeff.wessling@qualifacts.com> wrote in message
news:%230DGLNrRFHA.2964@TK2MSFTNGP15.phx.gbl...
> This seems like it should be a fairly straightforward mapping task, but
> I'm having trouble putting it together.
>
> I have a file that has lineitems that have an ID, the ID may be repeated
> for multiple lines. Each line also has an amount. How can I construct a
> map to sum up all the amount for lines with the same ID.
>
> Something like....
>
> <item>
> <id>0001</id><amount>100</amount>
> </item>
> <item>
> <id>0001</id><amount>50</amount>
> </item>
> <item>
> <id>0002</id><amount>100</amount>
> </item>
> <item>
> <id>0002</id><amount>75</amount>
> </item>
>
> - to -
>
> <record>
> <id>0001</id><TotalAmount>150</amount>
> </record>
> <record>
> <id>0002</id><TotalAmount>175</amount>
> </record>
>
> Any help would be most appreciated. Thanks!
>
|
|
|
|
|