B
Bryce (Work)
Here is the xml I'm working with:
<result>
<EFORM>
<testNode>
<section1>
<string1>ADAM</string1>
<integer1>55</integer1>
</section1>
</testNode>
</EFORM>
<EFORM>
<testNode>
<section1>
<string1>JOHN</string1>
<integer1>43</integer1>
</section1>
</testNode>
</EFORM>
<EFORM>
<testNode>
<section1>
<string1>ADAM</string1>
<integer1>22</integer1>
</section1>
</testNode>
</EFORM>
<EFORM>
<testNode>
<section1>
<string1>JOHN</string1>
<integer1>15</integer1>
</section1>
</testNode>
</EFORM>
</result>
What I'm trying to do is group by <string1> and sum <integer1>
for example:
JOHN 58
ADAM 77
Using Muenchian method, I can count the number of nodes for each
group, but am having difficulty getting the sum. Since I don't 100%
understand the code to do the grouping, I'm having difficutly. Here's
what I have for Counting:
<xslout:key name="keyname" match="EFORM"
use="testNode/Section1/string1" />
<xslout:template match="/">
<summary>
<xslout:for-each select="//EFORM[count(. | key('keyname',
testNode/Section1/string1)[1]) = 1]">
<xslout:sort select="testNode/Section1/string1"/>
<summaryGroup>
<summaryField>
<xslout:value-of select="testNode/Section1/string1"/>
</summaryField>
<summaryvalue>
<xslout:value-of select="count(key('keyname',
testNode/Section1/string1))"/>
</summaryvalue>
</summaryGroup>
</xslout:for-each>
</summary>
</xslout:template>
I'm not sure what I shoudl put in to do the sum... Or even if I can do
it this way.
Any help is appreciated.
Bryce
<result>
<EFORM>
<testNode>
<section1>
<string1>ADAM</string1>
<integer1>55</integer1>
</section1>
</testNode>
</EFORM>
<EFORM>
<testNode>
<section1>
<string1>JOHN</string1>
<integer1>43</integer1>
</section1>
</testNode>
</EFORM>
<EFORM>
<testNode>
<section1>
<string1>ADAM</string1>
<integer1>22</integer1>
</section1>
</testNode>
</EFORM>
<EFORM>
<testNode>
<section1>
<string1>JOHN</string1>
<integer1>15</integer1>
</section1>
</testNode>
</EFORM>
</result>
What I'm trying to do is group by <string1> and sum <integer1>
for example:
JOHN 58
ADAM 77
Using Muenchian method, I can count the number of nodes for each
group, but am having difficulty getting the sum. Since I don't 100%
understand the code to do the grouping, I'm having difficutly. Here's
what I have for Counting:
<xslout:key name="keyname" match="EFORM"
use="testNode/Section1/string1" />
<xslout:template match="/">
<summary>
<xslout:for-each select="//EFORM[count(. | key('keyname',
testNode/Section1/string1)[1]) = 1]">
<xslout:sort select="testNode/Section1/string1"/>
<summaryGroup>
<summaryField>
<xslout:value-of select="testNode/Section1/string1"/>
</summaryField>
<summaryvalue>
<xslout:value-of select="count(key('keyname',
testNode/Section1/string1))"/>
</summaryvalue>
</summaryGroup>
</xslout:for-each>
</summary>
</xslout:template>
I'm not sure what I shoudl put in to do the sum... Or even if I can do
it this way.
Any help is appreciated.
Bryce