ChildAxis.java 666 B

12345678910111213141516171819202122232425262728
  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 child:: step in a path expression. */
  6. public class ChildAxis extends TreeScanner
  7. {
  8. public static ChildAxis make (NodePredicate type)
  9. {
  10. ChildAxis axis = new ChildAxis();
  11. axis.type = type;
  12. return axis;
  13. }
  14. public void scan (AbstractSequence seq, int ipos, PositionConsumer out)
  15. {
  16. int child = seq.firstChildPos(ipos, type);
  17. while (child != 0)
  18. {
  19. out.writePosition(seq, child);
  20. child = seq.nextMatching(child, type, -1, false);
  21. }
  22. }
  23. }