RE: [xsl] Sum & Sort & Maxvalue

Subject: RE: [xsl] Sum & Sort & Maxvalue
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Sat, 6 Mar 2004 17:46:30 +0100
> -----Original Message-----
> From: Florian Mueller
>
> I have a complex problem. I dont know if i can explain it correctly.
>

Hi,

Given your input XML, the following

<xsl:key name="acts-day-name" match="activity"
         use="concat(ancestor::day/@date,@name)" />

will give you a handle to the unique activity names for a given day when
used in combination with a template like

<xsl:template match="day">
  <xsl:variable name="vacthelp"
         select="gv/activity[generate-id(.)=
           generate-id(
             key('acts-day-name', concat(
               current()/@date, @name)
                )[1])]" />
  ...
</xsl:template>

The trick then seems to be to construct a variable like

<xsl:variable name="vacts">
  <xsl:for-each select="$vacthelp">
    <activity name="{@name}">
      <hits><xsl:value-of
select="sum(ancestor::day/gv/activity[@name=current()/@name]/hits)"
/></hits>
    </act>
  </xsl:for-each>
</xsl:variable>

Then apply-templates, using the node-set extension function

<xsl:apply-templates select="ext:node-set($vacts)" />

I have been trying this with a sort on the hits-node, but it didn't seem to
be working. Just posting already since it seems that mainly the summing was
bothering you up to here, and in this way at least, I got the numbers
right..


Hope this helps!

Cheers,

Andreas


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread