ParentAxis.java 646 B

1234567891011121314151617181920212223242526
  1. // Copyright (c) 2003 Per M.A. Bothner.
  2. // This is free software; for terms and warranty disclaimer see ./COPYING.
  3. package gnu.kawa.xml;
  4. import gnu.lists.*;
  5. /** Used to implement a parent:: step in a path expression. */
  6. public class ParentAxis extends TreeScanner
  7. {
  8. public static ParentAxis make (NodePredicate type)
  9. {
  10. ParentAxis axis = new ParentAxis();
  11. axis.type = type;
  12. return axis;
  13. }
  14. public void scan (AbstractSequence seq, int ipos, PositionConsumer out)
  15. {
  16. ipos = seq.parentPos(ipos);
  17. int end = seq.endPos();
  18. if (ipos != end && type.isInstancePos(seq, ipos))
  19. out.writePosition(seq, ipos);
  20. }
  21. }