Subject: [xsl] Sum & Sort & Maxvalue From: Florian Mueller <jjdm@xxxxxxxx> Date: Fri, 05 Mar 2004 14:27:39 +0100 |
Hello I have a complex problem. I dont know if i can explain it correctly. First, i have the following code: xml ---------------------------------------- <day date="01.03.2004"> <users>1</users> <gv name="Offerte Neu"> <hits>2</hits> <activity name="Ermittlung eines Produktes"> <hits>2</hits> </activity> </gv> <gv name="SimulatorWeb"> <hits>1</hits> <activity name="SimulatorDummy"> <hits>1</hits> </activity> <activity name="Ermittlung eines Produktes"> <hits>3</hits> </activity> </gv> <gv name="CIS"> <hits>1</hits> <activity name="Vertrags Anzeige"> <hits>1</hits> </activity> <activity name="Vertrags Suche"> <hits>1</hits> </activity> </gv> <gv name="Muster"> <hits>11</hits> <activity name="Muster"> <hits>11</hits> </activity> </gv> <gv name="Mahninfo"> <hits>1</hits> <activity name="Mahninfo"> <hits>1</hits> </activity> </gv> </day> <day date="02.03.2004"> <users>2</users> <gv name="Offerte Neu"> <hits>3</hits> <activity name="Erfassung Produktedaten"> <hits>1</hits> </activity> <activity name="Ermittlung eines Produktes"> <hits>3</hits> </activity> </gv> <gv name="Mahninfo"> <hits>3</hits> <activity name="Mahninfo"> <hits>3</hits> </activity> </gv> </day> ---------------------------------------- xsl ---------------------------------------- <xsl:for-each select="//day"> <xsl:variable name="day" select="."/> <xsl:value-of select="normalize-space($day/@date) <xsl:for-each select="//gv/activity[generate-id()=generate-id(key('activity_key',@name))]"> <xsl:variable name="uname" select="@name"/> <xsl:variable name="activity" select="$day/gv/activity[@name=$uname]/@name"/> <xsl:variable name="summe" select="sum($activity/../..//activity[@name=$uname]/hits)"/> <xsl:sort data-type="number" order="descending"> <xsl:value-of select="$summe"/> </xsl:sort> <xsl:if test="$summe>0"> <xsl:value-of select="$activity"/> <b><xsl:value-of select="$summe"/></b> </xsl:if> </xsl:for-each> </xsl:for-each> ---------------------------------------- My goal is the following sorted list of activities during a day: ---------------------------------------- 01.03.2004 Muster 11 Ermittlung eines Produktes 5 Mahninfo 1 SimulatorDummy 1 Vertrags Anzeige 1 Vertrags Suche 1 03.03.2004 Muster 4 Ermittlung eines Produktes 2 Mahninfo 2 Aufbereitung Offerte 1 Erfassung Produktedaten 1 CIS 1 ---------------------------------------- The xsl-script doesnt work properly. The result is this ---------------------------------------- 01.03.2004 Muster 11 Ermittlung eines Produktes 5 SimulatorDummy 1 Vertrags Anzeige 1 Vertrags Suche 1 Mahninfo 1 03.03.2004 Ermittlung eines Produktes 4 Aufbereitung Offerte 2 Erfassung Produktedaten 3 ---------------------------------------- The problem is, that i have to list every activity only one time although the same activity is in several gv-tags. Probably someone could help me. The next problem is to get the maximum-value of the activity-hits. I have a recursive template with i can get the maximum value of a list. Thats no problem. But now there's another situation. I first have to sum-up all the hits of one activity and then i could get the maximum of all the sum-up hits. Someone understand anything and have a solution for my problems? Kindly regards Florian Mueller XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] sum value to one variable, Michael Kay | Thread | RE: [xsl] Sum & Sort & Maxvalue, Andreas L. Delmelle |
[xsl] sum value to one variable, Dionisio Ruiz de Zar | Date | Re: [xsl] Accessing specific repeti, David Carlisle |
Month |