Subject: Re: [xsl] Restrictind a set of notes to within a group From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Thu, 19 Apr 2012 10:24:11 -0400 |
'.00')"/>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),
<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?
You have to work with those sessions that are in the current group. Rather, you are looking at all sessions and getting the total sum.
<xsl:value-of select="format-number(sum(current-group()/Notes/@hours-worked),'.00')"/>
You've already correctly created the groups, you just aren't using them having created them.
BTW, the <xsl:for-each select="."> is meaningless and does nothing except render your context list to be only a single item which is not useful. Although you don't need the set of groups in your solution, not having that <xsl:for-each> would give you more information about the current group within the set of groups.
-- Public XSLT, XSL-FO, UBL and code list classes in Europe -- May 2012 Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Restrictind a set of note, Martin Honnen | Thread | Re: [xsl] Restrictind a set of note, Mark |
Re: [xsl] Restrictind a set of note, Martin Honnen | Date | Re: [xsl] Restrictind a set of note, Mark |
Month |