[xsl] Traversing the tree

Subject: [xsl] Traversing the tree
From: "Agnisys Technology \(P\) Ltd." <agnisys@xxxxxxxxx>
Date: Thu, 8 Sep 2005 14:09:50 -0700 (PDT)
  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 :
          <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>
          <reg  offset="6"> A8 </reg>
          <reg            > A9 </reg>
          <reg            > A10 </reg>

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.


Click here to donate to the Hurricane Katrina relief effort.

Current Thread