[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

Subject: Re: Continuously add to a parameter at each call
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Wed, 9 Nov 2005 15:52:20 -0600
explain for example about wbs
On 11/9/05, Emil Soosaithasan <emils@xxxxxxxxxxxxxxxx> wrote:
> Jon
>
> Sorry for not including the cost per each task but your guess is right
> on the money.  I like the idea of grouping rather than going through
> many iterative loops but I am new to the XSL world and have no
> experience in grouping.  I will try to look at the faq on grouping but
> if you have some time, please give me a small sample code on how to
> group the tasks.

Well, a query took longer to run then I thought and I have a meeting a
few minutes so I don't have time to start anything else.  I'll give a
small example and try to explain my thinking.  This example is a
rather crudy one though, and there are better generic examples out
there.

Assuming this is our structure:



<Tasks>
<Task><Name>Hardware</Name><OutlineLevel>1</OutlineLevel><WBS>1</WBS></Task>
<Task><Name>Bringup</Name><WBS>1.1</WBS><Cost>12</Cost></Task>
<Task><Name>Testing</Name><WBS>1.2</WBS><Cost>22</Cost></Task>
<Task><Name>Software</Name><OutlineLevel>1</OutlineLevel><WBS>2</WBS></Task>
<Task><Name>Development</Name><WBS>2.1</WBS><Cost>1</Cost></Task>
<Task><Name>Test</Name><WBS>2.2</WBS><Cost>3</Cost></Task>
</Tasks>


First, when you see anything that is similar to "For  0 to n in
S[0...n] do y if x is true", you know you can just ask for the nodes
that fufill that condition.  In our case, we want to sum up the work
value for all  those tasks that are "under" a task with the broader
OutlineLevel.  Then we want to sum all those that belong to the same
hierarchy, indicated by the digit before the period.

  <xsl:template match="Tasks">

    <xsl:for-each select="Task[OutlineLevel]">
   <!-- I now have a node set consisting of the Task elements that had
a child OutlineLevel Element-->
      <xsl:value-of select="Name" /><xsl:text>
</xsl:text>

<!-- give me the sum of all the following Task elements that start
with the same WBS pattern.  You'll notice this is a bit crude, since
literally it looks at all the following task elements, but
optimization can be done later with better understanding-->

<xsl:variable name="level" select="WBS" />
<xsl:value-of select="sum(following-sibling::Task[substring-before(WBS,'.')
= $level]/Cost)" />
<xsl:text>
</xsl:text>
    </xsl:for-each>

  </xsl:template>





Jon Gorman

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.