Re: [xsl] Traversing the tree

Subject: Re: [xsl] Traversing the tree
From: "Agnisys Technology \(P\) Ltd." <agnisys@xxxxxxxxx>
Date: Fri, 9 Sep 2005 13:31:20 -0700 (PDT)
  My real problem is a little more complex as it turns out, and I'm stuck again!
  What if instead of using the count or sum functions, I need to use my own function for each of
the nodes after the one with an "offset"? Can I still use some creative Xpath operation?

  For example: 

        <reg                > A1 </reg>
        <reg     offset="5" > A2 </reg>
        <reg                > A3 </reg>
        <reg                > A4 </reg>

Assume there is a "sizeNode" function that returns a "size" of "section".
sizeNode(section_foo) =  10
sizeNode(section_bar) = 100

So, the output of the above should be :
A1          :   0
A2          :   5
A3          :   6
section_foo :   7
section_bar :  17
A4          : 117

So now I cannot use the following because the "size" of each "section" could be different. 
sum($x/@offset) + 
(count(preceding-sibling::reg|preceding-sibling::section) -

I need some way to add up "size"s of all the nodes after (and including) the node with an "offset"

Once again I'm tempted to use a for loop and have a running counter, but I'm sure there is a
better way.

I would appreciate any help/pointer in this regard. 

P.S: Jay thanks for your effort, for me it was more food for thought.

--- "Agnisys Technology (P) Ltd." <agnisys@xxxxxxxxx> wrote:

> David,
>   Your alternate strategy works well and solves the problem.
>   Although, I do need to study it carefully to understand how it is doing it!
> Thanks,
> Anupam.

Click here to donate to the Hurricane Katrina relief effort.

Current Thread