XSLT: get a count of elements in buckets/groupings?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a simple xml data set like:
<raw><br/>
<total>2800</total><br/>
<total>4300</total><br/>
<total>600</total><br/>
<total>3200</total><br/>
<total>7400</total><br/>
...<br/>
</raw>
What I need to do is count these in buckets of 2500, without knowing what the maximum value is. I can do this easily if I know the max value (example below), but how can I dynamically generate the groupings?
<TotalNum100to2500><br/>
<xsl:value-of select="count(msxsl:node-set($data)/total[number(.)&gt;=100 and number(.)&lt;2500])"/><br/>
</TotalNum100to2500> <br/>
<TotalNum2500to5000><br/>
<xsl:value-of select="count(msxsl:node-set($data)/total[number(.)&gt;2500 and number(.)&lt;5000])"/><br/>
</TotalNum2500to5000> <br/>
<TotalNum5000to7500><br/>
<xsl:value-of select="count(msxsl:node-set($data)/total[number(.)&gt;5000 and number(.)&lt;7500])"/><br/>
</TotalNum5000to7500>

View the full article
 
Back
Top