xsl-list
[Top] [All Lists]

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

2012-04-19 09:22:04
Mark wrote:
have an xml file like
<Month>
<Date day=”1”>
<Session task=”task1”>
<Notes hours-worked=”1.5”/>
</Session>
<Session task=”task2”>
Notes hours-worked=”5”/>
<Session task=”task1”>
<Notes hours-worked=”3”/>
</Session>
</Date>
<Date day=”2”>
....
</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/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--