I have created a UDT that has two different fields. An activity name field and a completed date field. I have also created an xsl sheet that takes the activity name field and if it is one thing, then the Points column is X. If the activity name is another thing then the points column is XX. What I need to do now is create a forth column called Total and have that be a running total column. I'm assuming that I need to do this via a variable of some sort but I'm new to xsl and I'm unsure of how to accomplish this. Can it be done? Is there a better way to get the "sum" of my points column? I simply want the total or sum of all points that a person has accumulated by their entered activities. Thanks in advance.
Activity |
Completed Date |
Points |
Total |
Gym |
2/1/2007 |
5 |
|
HealthyU |
2/5/2007 |
15 |
|
Gym |
3/5/2007 |
5 |
|
Here is my xls file.
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:udt="DotNetNuke/UserDefinedTable">
<xsl:output method="xml" version="1.0" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/udt:UserDefinedTable">
<xsl:variable name ="NameOfCurrentUser" select ="udt:Context/udt:UserName"/>
<xsl:variable name ="IsAdministrator" select ="udt:Context/udt:IsAdministratorRole='true'"/>
<xsl:variable name ="NameOfCreatedByColumn"><xsl:value-of select="udt:Fields[udt:FieldType='CreatedBy']/udt:ValueColumn"
/>_UDT_Original</xsl:variable>
<!-- Sorting Support-->
<xsl:variable name="OrderBy" select="//udt:Fields[udt:UserDefinedFieldId=//udt:Context/udt:OrderBy]/udt:SortColumn"/>
<xsl:variable name="OrderDirection" select="//udt:Context/udt:OrderDirection"/>
<xsl:variable name="OrderType">
<xsl:variable name ="DataType" select ="//udt:Fields[udt:UserDefinedFieldId=//udt:Context/udt:OrderBy]/udt:FieldType"/>
<xsl:choose>
<xsl:when test="$DataType='Int32' or $DataType='Decimal' or $DataType='Currency'">number</xsl:when>
<xsl:otherwise>text</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<table cellspacing="0" cellpadding="4" border="0" style="border-width:0px;border-collapse:collapse;">
<tr class="NormalBold UDT_Table_Head">
<th></th>
<xsl:for-each select="udt:Fields">
<xsl:if test="udt:Visible='true' or udt:Visible='True'">
<th>
<xsl:value-of select="udt:FieldTitle" />
</th>
</xsl:if>
</xsl:for-each>
<th>Points</th>
<th>Total</th>
</tr>
<xsl:for-each select="udt:Data[*[name()=$NameOfCreatedByColumn]=$NameOfCurrentUser or $IsAdministrator]">
<xsl:variable name="id" select="udt:UserDefinedRowId" />
<tr>
<xsl:variable name="PointsTotal">5</xsl:variable>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position() mod 2 = 1">Normal UDT_Table_AlternateItem</xsl:when>
<xsl:otherwise>Normal UDT_Table_Item</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<td>
<xsl:if test="udt:EditLink">
<a>
<xsl:attribute name="href">
<xsl:value-of select="udt:EditLink" />
</xsl:attribute>
<img border="0" alt="edit">
<xsl:attribute name="src">
<xsl:value-of select="//udt:Context/udt:ApplicationPath" />/images/edit.gif
</xsl:attribute>
</img>
</a>
</xsl:if>
</td>
<td>
<xsl:value-of select="udt:Activity" />
</td>
<td>
<xsl:value-of select="udt:CompletedDate_UDT_Value" />
</td>
<xsl:if test="udt:Activity='Gym'">
<td>
<xsl:value-of select="5" />
</td>
</xsl:if>
<xsl:if test="udt:Activity='Lunch n Learn'">
<td>
<xsl:value-of select="10" />
</td>
</xsl:if>
<xsl:if test="udt:Activity='Healthyu'">
<td>
<xsl:value-of select="25" />
</td>
</xsl:if>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>