[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Sum & Sort & Maxvalue

Subject: RE: Sum & Sort & Maxvalue
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Sat, 6 Mar 2004 17:46:30 +0100
sort least sum
> -----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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.