In MS Project, all tasks whether low-level or top-level are grouped as
tasks, for example:
<Tasks>
<Task><Name>Hardware</Name><OutlineLevel>1</OutlineLevel><WBS>1</WBS></T
ask>
<Task><Name>Bringup</Name><WBS>1.1</WBS></Task>
<Task><Name>Testing</Name><WBS>1.2</WBS></Task>
<Task><Name>Software</Name><OutlineLevel>1</OutlineLevel><WBS>2</WBS></T
ask>
<Task><Name>Development</Name><WBS>2.1</WBS></Task>
<Task><Name>Test</Name><WBS>2.2</WBS></Task>
</Task>
The way I group these is by <WBS>, if you notice carefully - "Hardware"
has a <WBS> of "1" which means it's a Top-Level task. "Bringup" is a
low-level task that falls under "Hardware" because it has a <WBS> of
"1.1". "Testing" is also another low level task under "Hardware".
Similar arguments can be made for the Top-Level task "Software" and its
tasks.
Looks like a pretty standard varient of a grouping problem, no need to
go through a bunch of loops. Group the elements or gather via xpath
expressions.
I could give you more advice, but I can't for the life of me find a
"Cost" element in your example and don't have much time to look
closely at this right now.
I'll take a wild stab and guess it's something like this (although
guessing in cases involving Microsoft's xml schemas is always risky).
<Tasks>
<Task><Name>Hardware</Name><OutlineLevel>1</OutlineLevel><WBS>1</WBS></T
ask>
<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></T
ask>
<Task><Name>Development</Name><WBS>2.1</WBS><Cost>1</Cost></Task>
<Task><Name>Test</Name><WBS>2.2</WBS><Cost>3</Cost></Task>
</Task>
So if it is there is a couple of ways to select the proper nodesets.
1) For each task that has an outline element , sum the following
siblings that position is less then the next item to have an outline
element. Then to produce a grand total sum all Tasks that have a
Cost.
2) group all that start with the same digit ie (all 1.*, 2.*) by
grouping methods described in the faq. Run sum on the Cost nodes in
that nodeset.
In a broader set of advice either a) use recursion (think in lisp
terms with car and cdr) since you cannot change the value of a
variable or b) just group and use the sum as appropriate. I stil
haven't seen anything that would force someone to need to use
iterative loops. If you do just modify it to use a recursive
template.
Jon
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--