|
Subject: Re: [xsl] Traversing the tree From: "Agnisys Technology \(P\) Ltd." <agnisys@xxxxxxxxx> Date: Fri, 9 Sep 2005 13:31:20 -0700 (PDT) |
David,
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:
Input:
<top>
<a>
<reg > A1 </reg>
<reg offset="5" > A2 </reg>
<reg > A3 </reg>
<section>
section_foo
</section>
<section>
section_bar
</section>
<reg > A4 </reg>
</a>
</top>
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) -
count($x/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"
attribute.
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.
Anupam.
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.
http://store.yahoo.com/redcross-donate3/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Traversing the tree, Agnisys Technology \ | Thread | Re: [xsl] Traversing the tree, David Carlisle |
| RE: [xsl] Apply-templates - how to , Mike Schinkel | Date | Re: [xsl] Apply-templates - how to , David Carlisle |
| Month |