[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Restrictind a set of notes to within a group


Subject: Re: [xsl] Restrictind a set of notes to within a group
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Thu, 19 Apr 2012 16:21:46 +0200

Mark wrote:
have an xml file like
<Month>
<Date day=b1b>
<Session task=btask1b>
<Notes hours-worked=b1.5b/>
</Session>
<Session task=btask2b>
Notes hours-worked=b5b/>
<Session task=btask1b>
<Notes hours-worked=b3b/>
</Session>
</Date>
<Date day=b2b>
....
</Date>
</Month>
For the month, I want to sum all the hours-worked for each task:

I have tried several expressions, but failed. This gives me the total
hours worked on all tasks rather than each individual task:
<xsl:for-each-group select="Date/Session" group-by="@task">
<xsl:for-each select=".">
<fo:block xsl:use-attribute-sets="subdiv2">
<xsl:value-of select="@task"/>
<xsl:text> (</xsl:text>
<xsl:value-of
select="format-number(sum(../../Date/Session/Notes/@hours-worked),
'.00')"/>
<xsl:text>) </xsl:text>
</fo:block>
</xsl:for-each>
</xsl:for-each-group>
How do I restrict the total to just the hours-worked on each specific task?

I think you want
sum(current-group()/Notes/@hours-worked)
you will need to throw out the 'for-each' inside the 'for-each-group' however



--


	Martin Honnen --- MVP Data Platform Development
	http://msmvps.com/blogs/martin_honnen/


Current Thread
Keywords
xml