/** * Evaluate as an expression. We rely on the fact that when these instructions * are generated by XQuery, there will always be a valueExpression to evaluate * the content */ public Item evaluateItem(XPathContext context) throws XPathException { Controller controller = context.getController(); XPathContext c2 = context.newMinorContext(); c2.setOrigin(this); SequenceOutputter seq = controller.allocateSequenceOutputter(1); PipelineConfiguration pipe = controller.makePipelineConfiguration(); pipe.setHostLanguage(getHostLanguage()); seq.setPipelineConfiguration(pipe); c2.setTemporaryReceiver(seq); process(c2); seq.close(); Item item = seq.getFirstItem(); seq.reset(); return item; }
@Override public Sequence<?> evaluate(Expression expr, XPathContext context) throws XPathException { Controller controller = context.getController(); Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(20); seq.getPipelineConfiguration().setHostLanguage(expr.getPackageData().getHostLanguage()); context.setReceiver(seq); seq.open(); expr.process(context); seq.close(); context.setReceiver(saved); Sequence<?> val = seq.getSequence(); seq.reset(); return val; }
/** * Allocate a SequenceOutputter for a new output destination. Reuse the existing one * if it is available for reuse (this is designed to ensure that the TinyTree structure * is also reused, creating a forest of trees all sharing the same data structure) * @param size the estimated size of the output sequence * @return SequenceOutputter the allocated SequenceOutputter */ public SequenceOutputter allocateSequenceOutputter(int size) { if (reusableSequenceOutputter != null) { SequenceOutputter out = reusableSequenceOutputter; reusableSequenceOutputter = null; return out; } else { return new SequenceOutputter(this, size); } }
/** * Evaluate as an expression. We rely on the fact that when these instructions * are generated by XQuery, there will always be a valueExpression to evaluate * the content */ public Item evaluateItem(XPathContext context) throws XPathException { Controller controller = context.getController(); Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(1); seq.getPipelineConfiguration().setHostLanguage(getPackageData().getHostLanguage()); context.setReceiver(seq); process(context); seq.close(); context.setReceiver(saved); Item item = seq.getFirstItem(); seq.reset(); return item; }
seq.setPipelineConfiguration(controller.makePipelineConfiguration()); seq.open(); TeeOutputter tee = new TeeOutputter(context.getReceiver(), seq); tee.setPipelineConfiguration(controller.makePipelineConfiguration()); seq.close(); List list = seq.getList(); if (list.isEmpty()) { state = EMPTY; seq.reset();
PipelineConfiguration pipe = controller.makePipelineConfiguration(); pipe.setHostLanguage(exp.getHostLanguage()); seq.setPipelineConfiguration(pipe); c2.setTemporaryReceiver(seq); seq.open(); exp.process(c2); seq.close(); ValueRepresentation val = seq.getSequence(); seq.reset(); return val;
PipelineConfiguration pipe = controller.makePipelineConfiguration(); pipe.setHostLanguage(getHostLanguage()); seq.setPipelineConfiguration(pipe); } else { TreeReceiver tr = new TreeReceiver(validator); tr.setPipelineConfiguration(seq.getPipelineConfiguration()); c2.setReceiver(tr); ini = tr; NodeInfo result = (NodeInfo)seq.popLastItem(); seq.reset(); return result;
PipelineConfiguration pipe = controller.makePipelineConfiguration(); pipe.setHostLanguage(getContainer().getHostLanguage()); seq.setPipelineConfiguration(pipe); c2.setTemporaryReceiver(seq); process(c2); Item item = seq.getFirstItem(); seq.reset(); return item;
PipelineConfiguration pipe = controller.makePipelineConfiguration(); pipe.setHostLanguage(getContainer().getHostLanguage()); seq.setPipelineConfiguration(pipe); c2.setTemporaryReceiver(seq); SequenceIterator result = Value.getIterator(seq.getSequence()); seq.reset(); return result;
/** * Helper method to construct an iterator over the results of the expression when all that * the expression itself offers is a process() method. This builds the entire results of the * expression as a sequence in memory and then iterates over it. * * @param context the dynamic evaluation context * @return an iterator over the results of the expression * @throws XPathException if a dynamic error occurs */ public static SequenceIterator<?> getIteratorFromProcessMethod( Expression exp, XPathContext context) throws XPathException { Controller controller = context.getController(); assert controller != null; Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(20); seq.getPipelineConfiguration().setHostLanguage(exp.getPackageData().getHostLanguage()); context.setReceiver(seq); exp.process(context); context.setReceiver(saved); seq.close(); return seq.iterate(); }
Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(1); seq.getPipelineConfiguration().setHostLanguage(getPackageData().getHostLanguage()); } else { TreeReceiver tr = new TreeReceiver(validator); tr.setPipelineConfiguration(seq.getPipelineConfiguration()); context.setReceiver(tr); ini = tr; NodeInfo result = (NodeInfo) seq.popLastItem(); seq.reset(); return result;
PipelineConfiguration pipe = controller.makePipelineConfiguration(); pipe.setHostLanguage(getHostLanguage()); seq.setPipelineConfiguration(pipe); c2.setTemporaryReceiver(seq); process(c2); seq.close(); return seq.iterate();
XPathContext c2 = context.newMinorContext(); c2.setOrigin(this); SequenceOutputter out = new SequenceOutputter(); out.setPipelineConfiguration(pipe); c2.setReceiver(out); try { process(c2); return Value.getIterator(out.getSequence()); } catch (XPathException err) { if (err instanceof ValidationException) {
PipelineConfiguration pipe = controller.makePipelineConfiguration(); pipe.setXPathContext(context); SequenceOutputter out = new SequenceOutputter(pipe); if (copyForUpdate) { out.setTreeModel(TreeModel.LINKED_TREE); return out.getSequence().iterate();
/** * Close the destination, allowing resources to be released. Saxon calls this method when * it has finished writing to the destination. */ public void close() throws SaxonApiException { try { sequenceOutputter.close(); closed = true; } catch (XPathException e) { throw new SaxonApiException(e); } }
/** * Return the result sequence, after it has been constructed. * <p>This method should not be called until the destination has been closed.</p> * * @return the the result sequence * @throws IllegalStateException if called during the execution of the process that * is writing the tree. */ public XdmValue getXdmValue() { if (!closed) { throw new IllegalStateException("The result sequence has not yet been closed"); } return XdmValue.wrap(sequenceOutputter.getSequence()); }
/** * Allocate a SequenceOutputter. Used from generated bytecode. * * @param context dynamic XPath context * @param hostLang host language (XSLT/XQuery) * @return the allocated SequenceOutputter * @see com.saxonica.ee.bytecode.util.CompilerService */ /*@Nullable*/ public static SequenceOutputter allocateSequenceOutputter(XPathContext context, int hostLang) { Controller controller = context.getController(); SequenceOutputter seq = controller.allocateSequenceOutputter(20); seq.getPipelineConfiguration().setHostLanguage(hostLang); return seq; }
/** * Clear the contents of the SequenceOutputter and make it available for reuse */ public void reset() { list = new ArrayList(Math.max(list.size()+10, 50)); if (controller != null && adviseReuse()) { controller.reuseSequenceOutputter(this); } }
/** * Evaluate as an expression. We rely on the fact that when these instructions * are generated by XQuery, there will always be a valueExpression to evaluate * the content */ public Item evaluateItem(XPathContext context) throws XPathException { Controller controller = context.getController(); Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(1); seq.getPipelineConfiguration().setHostLanguage(getPackageData().getHostLanguage()); context.setReceiver(seq); process(context); seq.close(); context.setReceiver(saved); Item item = seq.getFirstItem(); seq.reset(); return item; }
seq.setPipelineConfiguration(controller.makePipelineConfiguration()); seq.open(); TeeOutputter tee = new TeeOutputter(context.getReceiver(), seq); tee.setPipelineConfiguration(controller.makePipelineConfiguration()); seq.close(); List list = seq.getList(); if (list.isEmpty()) { state = EMPTY; seq.reset();