01: // Copyright (c) 2003 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.kawa.xml;
05:
06: import gnu.lists.*;
07:
08: /** Used to implement a ancestor:: step in a path expression. */
09:
10: public class AncestorAxis extends TreeScanner {
11: public static AncestorAxis make(NodePredicate type) {
12: AncestorAxis axis = new AncestorAxis();
13: axis.type = type;
14: return axis;
15: }
16:
17: private static void scan(AbstractSequence seq, int ipos, int end,
18: NodePredicate type, PositionConsumer out) {
19: ipos = seq.parentPos(ipos);
20: if (ipos != end) {
21: scan(seq, ipos, end, type, out);
22: if (type.isInstancePos(seq, ipos))
23: out.writePosition(seq, ipos);
24: }
25: }
26:
27: public void scan(AbstractSequence seq, int ipos,
28: PositionConsumer out) {
29: scan(seq, ipos, seq.endPos(), type, out);
30: }
31: }
|