[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Traversing the tree

Subject: Re: Traversing the tree
From: "Agnisys Technology \(P\) Ltd." <agnisys@xxxxxxxxx>
Date: Fri, 9 Sep 2005 13:31:20 -0700 (PDT)
a1 technology
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

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.