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

Traversing the tree

Subject: Traversing the tree
From: "Agnisys Technology \(P\) Ltd." <agnisys@xxxxxxxxx>
Date: Thu, 8 Sep 2005 14:09:50 -0700 (PDT)
traversing a tree
Hi,
  This is probably simple for the experts of the group but I can't figure this out. Problem I got
stuck on was how to find the closest preceding-sibling node with an offset attribute, then count
the nodes that don't have the attribute since that node.
 
Input :
<top>
     <a>
          <reg                > A1 </reg>
          <reg                > A2 </reg>
          <reg  offset="10"   > A3 </reg>
          <reg                > A4 </reg>
          <reg                > A5 </reg>
          <reg  offset="24"   > A6 </reg>
          <reg                > A7 </reg>
      </a>
      <a>
          <reg  offset="6"> A8 </reg>
          <reg            > A9 </reg>
      </a>
      <a>
          <reg            > A10 </reg>
      </a>
 </top>

Output:
A1 : 0
A2 : 1
A3 : 10
A4 : 11
A5 : 12
A6 : 24
A7 : 25
A8 : 6
A9 : 7
A10: 0

So, start with 0 and count unless @offset is encountered, if so, jump to the offset and start
counting again.
Offsets are guaranteed to be monotonically increasing, although I do need to create a test
elsewhere that verifies that it does.

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.