Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - XSLT Grouping and Counting Question [Thread Next] Re: XSLT Grouping and Counting QuestionTo: NULL Date: 2/6/2009 5:55:00 PM John Galenski wrote:
> <xsl:for-each select="Report/Record[count(. | key('recs-by-status',
> Status)[1]) = 1]">
> <xsl:sort select="Status" />
> <xsl:value-of select="Status" /> = <xsl:value-of
> select="count(key('recs-by-status', Status))"/><br />
> Sales: <xsl:value-of
> select="count(Report/Record[Component='Sales'][Status=key('recs-by-status',
> Status)])"/><br />
Inside of the for-each a 'Record' element is the context node and that
way the
<xsl:value-of select="count(Report/Record
looks for 'Report/Record' descendants of that context 'Record' element.
I am not sure I understand your sample data correctly as you have not
provided much but don't you simply want
<xsl:value-of
select="count(key('recs-by-status',
Status)[normalize-space(Component) = 'Sales'])"/>
?
So for each group established by the key you would count those 'Record'
elements where the Component (after whitespace normalization) is 'Sales'.
> Training: xsl:value-of
> select="count(Report/Record[Component='Training'][Status=key('recs-by-status',
> Status)])"/><br />
Same here
<xsl:value-of
select="count(key('recs-by-status',
Status)[normalize-space(Component) = 'Training'])"/>
--
Martin Honnen
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
