| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.expr.flwor; |
| 9 |
|
| 10 |
import net.sf.saxon.expr.XPathContext; |
| 11 |
import net.sf.saxon.om.Item; |
| 12 |
import net.sf.saxon.om.SequenceIterator; |
| 13 |
import net.sf.saxon.trans.XPathException; |
| 14 |
import net.sf.saxon.value.Int64Value; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
public class ForClausePush extends TuplePush { |
| 20 |
|
| 21 |
protected TuplePush destination; |
| 22 |
protected ForClause forClause; |
| 23 |
|
| 24 |
public ForClausePush(TuplePush destination, ForClause forClause) { |
| 25 |
this.destination = destination; |
| 26 |
this.forClause = forClause; |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
@Override |
| 33 |
public void processTuple(XPathContext context) throws XPathException { |
| 34 |
SequenceIterator iter = forClause.getSequence().iterate(context); |
| 35 |
int pos = 0; |
| 36 |
Item next; |
| 37 |
while ((next = iter.next()) != null) { |
| 38 |
context.setLocalVariable(forClause.getRangeVariable().getLocalSlotNumber(), next); |
| 39 |
if (forClause.getPositionVariable() != null) { |
| 40 |
context.setLocalVariable( |
| 41 |
forClause.getPositionVariable().getLocalSlotNumber(), |
| 42 |
new Int64Value(++pos)); |
| 43 |
} |
| 44 |
destination.processTuple(context); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
@Override |
| 52 |
public void close() throws XPathException { |
| 53 |
destination.close(); |
| 54 |
} |
| 55 |
} |
| 56 |
|