Returns an axis iterator. @param qc query context @return iterator @throws QueryException query exception
(final QueryContext qc)
| 130 | * @throws QueryException query exception |
| 131 | */ |
| 132 | final BasicNodeIter iterator(final QueryContext qc) throws QueryException { |
| 133 | final Value value = qc.focus.value; |
| 134 | GNode gnode; |
| 135 | if(value instanceof final GNode node) { |
| 136 | gnode = node; |
| 137 | } else if(value instanceof final XQStruct struct) { |
| 138 | gnode = new JNode(struct); |
| 139 | } else { |
| 140 | throw value == null ? QueryError.NOCTX_X.get(info, this) : |
| 141 | QueryError.PATHNODE_X_X_X.get(info, this, value.type, value); |
| 142 | } |
| 143 | final BasicNodeIter iter = axis.iter(gnode, test); |
| 144 | return new BasicNodeIter() { |
| 145 | @Override |
| 146 | public GNode next() { |
| 147 | for(GNode node; (node = iter.next()) != null;) { |
| 148 | qc.checkStop(); |
| 149 | if(test.matches(node)) return node; |
| 150 | } |
| 151 | return null; |
| 152 | } |
| 153 | }; |
| 154 | } |
| 155 | |
| 156 | @Override |
| 157 | public final Expr optimize(final CompileContext cc) throws QueryException { |