Controller controller = context.getController();
XPathContext c2 = savedXPathContext.newMinorContext();
//c2.setOrigin(this);
// Fork the output: one copy goes to a SequenceOutputter which remembers the contents for
// use next time the variable is referenced; another copy goes to the current output destination.
SequenceOutputter seq = controller.allocateSequenceOutputter(20);
seq.setPipelineConfiguration(controller.makePipelineConfiguration());
seq.open();
TeeOutputter tee = new TeeOutputter(context.getReceiver(), seq);
tee.setPipelineConfiguration(controller.makePipelineConfiguration());
c2.setTemporaryReceiver(tee);
expression.process(c2);
seq.close();
List list = seq.getList();
if (list.isEmpty()) {
state = EMPTY;
} else {
reservoir = new Item[list.size()];
reservoir = (Item[])list.toArray(reservoir);
used = list.size();
state = ALL_READ;
}
// give unwanted stuff to the garbage collector
savedXPathContext = null;
seq.reset();
}
}