Beispiel #1
0
  @Override
  public NodeIter iter(final QueryContext ctx) throws QueryException {
    final Value v = checkCtx(ctx);
    if (!v.type.isNode()) NODESPATH.thrw(input, AxisStep.this, v.type);
    final AxisIter ai = axis.iter((ANode) v);

    final NodeCache nc = new NodeCache();
    for (ANode n; (n = ai.next()) != null; ) if (test.eval(n)) nc.add(n.finish());

    // evaluate predicates
    for (final Expr p : preds) {
      ctx.size = nc.size();
      ctx.pos = 1;
      int c = 0;
      for (int n = 0; n < nc.size(); ++n) {
        ctx.value = nc.get(n);
        final Item i = p.test(ctx, input);
        if (i != null) {
          // assign score value
          nc.get(n).score(i.score());
          nc.item[c++] = nc.get(n);
        }
        ctx.pos++;
      }
      nc.size(c);
    }
    return nc;
  }
Beispiel #2
0
 /**
  * Adds children of a sub node.
  *
  * @param ch child nodes
  * @param nc node cache
  */
 protected final void addDesc(final AxisMoreIter ch, final NodeCache nc) {
   for (ANode n; (n = ch.next()) != null; ) {
     nc.add(n.finish());
     addDesc(n.children(), nc);
   }
 }