1 4 package gnu.kawa.xml; 5 import gnu.lists.*; 6 7 8 9 public class PrecedingAxis extends TreeScanner 10 { 11 public static PrecedingAxis make (NodePredicate type) 12 { 13 PrecedingAxis axis = new PrecedingAxis(); 14 axis.type = type; 15 return axis; 16 } 17 18 private static void scan (AbstractSequence seq, int ipos, int end, 19 NodePredicate type, PositionConsumer out) 20 { 21 int parent = seq.parentPos(ipos); 22 if (parent == end) 23 return; 24 scan (seq, parent, end, type, out); 25 int child = seq.firstChildPos(parent); 26 if (child == 0) 27 return; 28 if (type.isInstancePos(seq, child)) 29 out.writePosition(seq, child); 30 for (;;) 31 { 32 child = seq.nextMatching(child, type, ipos, true); 33 if (child == 0) 34 break; 35 out.writePosition(seq, child); 36 } 37 } 38 39 public void scan (AbstractSequence seq, int ipos, PositionConsumer out) 40 { 41 scan(seq, ipos, seq.endPos(), type, out); 42 } 43 } 44 45 | Popular Tags |