|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Traversing the 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/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








