[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Continuously add to a parameter at each call
On 11/9/05, Emil Soosaithasan <emils@xxxxxxxxxxxxxxxx> wrote: > > To elaborate on my problem, For each of the Top Level Tasks - I have to > search through each Assignment - obtain the task that is related to the > assignment - check if the task obtained falls under the top-level task - > and if it does then get the cost. Why do you have to do this? Perhaps I'm missing something, but it's not clear why you can't just follow Michael's advice and do this in a more declartive way. Lets say you have the following XML (I have no idea what MSProject looks like) <doc> <hardware> <task type="a">12</task> <task type="b">12</task> <task type="a">22</task> </hardware> <software> <task type="a">2</task> <task type="b">42</task> <task type="a">5</task> </software> <analysis> <task type="a">1</task> <task type="b">3</task> <task type="a">2</task> </analysis> </doc> The following xslt script will give you totals for the value in each catagory and the grand total. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" /> <xsl:param name="type" select="'a'" /> <xsl:template match="/doc"> Value of hardware: <xsl:value-of select="sum(hardware/task[@type=$type])" /> Value of software: <xsl:value-of select="sum(software/task[@type=$type])" /> Value of analysis: <xsl:value-of select="sum(analysis/task[@type=$type])" /> Grand Total: <xsl:value-of select="sum(*/task[@type=$type])" /> </xsl:template> </xsl:stylesheet> If you really need to do this in a more procedural way, use some recursion, have a template that takes two parameters, a node set and a value. Call the same template with the node set of all the other nodes (position > 1) and the value increased by the amount in the first node. Do this until no nodes are in the list and print the list. Jon Gorman
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|