/** * Process this template, with the possibility of returning a tail call package if the template * contains any tail calls that are to be performed by the caller. * @param context the XPath dynamic context * @param rule the template rule that caused this template to be invoked. When a template has * a match pattern defined as a union, there can be more than one Rule referring to the same template, * and further calls on next-match or apply-imports need to know which one in in force * @return null if the template exited normally; but if it was a tail call, details of the call * that hasn't been made yet and needs to be made by the caller */ public TailCall applyLeavingTail(XPathContext context, Rule rule) throws XPathException { if (body==null) { // fast path for an empty template return null; } XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.setCurrentTemplateRule(rule); if (bodyIsTailCallReturner) { return ((TailCallReturner)body).processLeavingTail(c2); } else { body.process(c2); return null; } }
/** * Process this template, with the possibility of returning a tail call package if the template * contains any tail calls that are to be performed by the caller. * @param context the XPath dynamic context * @param rule the template rule that caused this template to be invoked. When a template has * a match pattern defined as a union, there can be more than one Rule referring to the same template, * and further calls on next-match or apply-imports need to know which one in in force * @return null if the template exited normally; but if it was a tail call, details of the call * that hasn't been made yet and needs to be made by the caller */ public TailCall applyLeavingTail(XPathContext context, Rule rule) throws XPathException { if (body==null) { // fast path for an empty template return null; } XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.setCurrentTemplateRule(rule); if (bodyIsTailCallReturner) { return ((TailCallReturner)body).processLeavingTail(c2); } else { body.process(c2); return null; } }
/** * Process this template, with the possibility of returning a tail call package if the template * contains any tail calls that are to be performed by the caller. * @param context the XPath dynamic context * @param rule the template rule that caused this template to be invoked. When a template has * a match pattern defined as a union, there can be more than one Rule referring to the same template, * and further calls on next-match or apply-imports need to know which one in in force * @return null if the template exited normally; but if it was a tail call, details of the call * that hasn't been made yet and needs to be made by the caller */ public TailCall applyLeavingTail(XPathContext context, Rule rule) throws XPathException { if (body==null) { // fast path for an empty template return null; } XPathContextMajor c2 = context.newContext(); c2.setOriginatingConstructType(Location.TEMPLATE); c2.setCurrentTemplateRule(rule); if (bodyIsTailCallReturner) { return ((TailCallReturner)body).processLeavingTail(c2); } else { body.process(c2); return null; } }
/** * Return an Iterator to iterate over the values of the sequence. * * @exception XPathException if any dynamic error occurs evaluating the * expression * @param context supplies the context for evaluation * @return a SequenceIterator that can be used to iterate over the result * of the expression */ public SequenceIterator iterate(XPathContext context) throws XPathException { SequenceIterator master = select.iterate(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.setCurrentTemplateRule(null); c2.setCurrentIterator(master); master = new ContextMappingIterator(this, c2); return master; }
/** * Return an Iterator to iterate over the values of the sequence. * * @exception XPathException if any dynamic error occurs evaluating the * expression * @param context supplies the context for evaluation * @return a SequenceIterator that can be used to iterate over the result * of the expression */ public SequenceIterator iterate(XPathContext context) throws XPathException { SequenceIterator master = select.iterate(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.setCurrentTemplateRule(null); c2.setCurrentIterator(master); master = new ContextMappingIterator(this, c2); return master; }
/** * Return an Iterator to iterate over the values of a sequence. The value of every * expression can be regarded as a sequence, so this method is supported for all * expressions. This default implementation relies on the process() method: it * "pushes" the results of the instruction to a sequence in memory, and then * iterates over this in-memory sequence. * <p>In principle instructions should implement a pipelined iterate() method that * avoids the overhead of intermediate storage.</p> * * @param context supplies the context for evaluation * @return a SequenceIterator that can be used to iterate over the result * of the expression * @throws XPathException if any dynamic error occurs evaluating the * expression */ /*@NotNull*/ public SequenceIterator<?> iterate(XPathContext context) throws XPathException { GroupIterator master = getGroupIterator(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.trackFocus(master); c2.setCurrentGroupIterator(master); c2.setCurrentTemplateRule(null); return new ContextMappingIterator<>(this, c2); }
/** * Return an Iterator to iterate over the values of a sequence. The value of every * expression can be regarded as a sequence, so this method is supported for all * expressions. This default implementation relies on the process() method: it * "pushes" the results of the instruction to a sequence in memory, and then * iterates over this in-memory sequence. * <p/> * In principle instructions should implement a pipelined iterate() method that * avoids the overhead of intermediate storage. * * @param context supplies the context for evaluation * @return a SequenceIterator that can be used to iterate over the result * of the expression * @throws XPathException if any dynamic error occurs evaluating the * expression */ public SequenceIterator iterate(XPathContext context) throws XPathException { GroupIterator master = getGroupIterator(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.setCurrentIterator(master); c2.setCurrentGroupIterator(master); c2.setCurrentTemplateRule(null); return new ContextMappingIterator(this, c2); }
/** * Return an Iterator to iterate over the values of a sequence. The value of every * expression can be regarded as a sequence, so this method is supported for all * expressions. This default implementation relies on the process() method: it * "pushes" the results of the instruction to a sequence in memory, and then * iterates over this in-memory sequence. * <p/> * In principle instructions should implement a pipelined iterate() method that * avoids the overhead of intermediate storage. * * @param context supplies the context for evaluation * @return a SequenceIterator that can be used to iterate over the result * of the expression * @throws XPathException if any dynamic error occurs evaluating the * expression */ public SequenceIterator iterate(XPathContext context) throws XPathException { GroupIterator master = getGroupIterator(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.setCurrentIterator(master); c2.setCurrentGroupIterator(master); c2.setCurrentTemplateRule(null); return new ContextMappingIterator(this, c2); }
/** * Return an Iterator to iterate over the values of a sequence. The value of every * expression can be regarded as a sequence, so this method is supported for all * expressions. This default implementation relies on the process() method: it * "pushes" the results of the instruction to a sequence in memory, and then * iterates over this in-memory sequence. * <p>In principle instructions should implement a pipelined iterate() method that * avoids the overhead of intermediate storage.</p> * * @param context supplies the context for evaluation * @return a SequenceIterator that can be used to iterate over the result * of the expression * @throws XPathException if any dynamic error occurs evaluating the * expression */ /*@NotNull*/ public SequenceIterator<?> iterate(XPathContext context) throws XPathException { GroupIterator master = getGroupIterator(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.trackFocus(master); c2.setCurrentGroupIterator(master); c2.setCurrentTemplateRule(null); return new ContextMappingIterator<>(this, c2); }
/** * Process the template call encapsulated by this package. * * @return another TailCall. This will never be the original call, but it may be the next * recursive call. For example, if A calls B which calls C which calls D, then B may return * a TailCall to A representing the call from B to C; when this is processed, the result may be * a TailCall representing the call from C to D. * @throws XPathException if a dynamic error occurs */ public TailCall processLeavingTail() throws XPathException { TemplateRule nh = (TemplateRule) rule.getAction(); nh.initialize(); XPathContextMajor c2 = evaluationContext.newContext(); c2.setOrigin(NextMatch.this); //c2.setOriginatingConstructType(LocationKind.TEMPLATE); c2.setLocalParameters(params); c2.setTunnelParameters(tunnelParams); c2.openStackFrame(nh.getStackFrameMap()); c2.setCurrentTemplateRule(rule); c2.setCurrentComponent(evaluationContext.getCurrentComponent()); // System.err.println("Tail call on template"); return nh.applyLeavingTail(c2); } }
/** * Process the template call encapsulated by this package. * * @return another TailCall. This will never be the original call, but it may be the next * recursive call. For example, if A calls B which calls C which calls D, then B may return * a TailCall to A representing the call from B to C; when this is processed, the result may be * a TailCall representing the call from C to D. * @throws XPathException if a dynamic error occurs */ public TailCall processLeavingTail() throws XPathException { TemplateRule nh = (TemplateRule) rule.getAction(); nh.initialize(); XPathContextMajor c2 = evaluationContext.newContext(); c2.setOrigin(NextMatch.this); //c2.setOriginatingConstructType(LocationKind.TEMPLATE); c2.setLocalParameters(params); c2.setTunnelParameters(tunnelParams); c2.openStackFrame(nh.getStackFrameMap()); c2.setCurrentTemplateRule(rule); c2.setCurrentComponent(evaluationContext.getCurrentComponent()); // System.err.println("Tail call on template"); return nh.applyLeavingTail(c2); } }
c2.setOrigin(this); c2.setCurrentIterator(iter); c2.setCurrentTemplateRule(null);
public TailCall processLeavingTail(XPathContext context) throws XPathException { Controller controller = context.getController(); SequenceIterator iter = select.iterate(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.setCurrentIterator(iter); c2.setCurrentTemplateRule(null); if (controller.isTracing()) { TraceListener listener = controller.getTraceListener(); while(true) { Item item = iter.next(); if (item == null) { break; } listener.startCurrentItem(item); action.process(c2); listener.endCurrentItem(item); } } else { while(true) { Item item = iter.next(); if (item == null) { break; } action.process(c2); } } return null; }
public TailCall processLeavingTail(XPathContext context) throws XPathException { Controller controller = context.getController(); GroupIterator groupIterator = getGroupIterator(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.setCurrentIterator(groupIterator); c2.setCurrentGroupIterator(groupIterator); c2.setCurrentTemplateRule(null); if (controller.isTracing()) { TraceListener listener = controller.getTraceListener(); while (true) { Item item = groupIterator.next(); if (item == null) { break; } listener.startCurrentItem(item); action.process(c2); listener.endCurrentItem(item); } } else { while (true) { Item item = groupIterator.next(); if (item == null) { break; } action.process(c2); } } return null; }
public TailCall processLeavingTail(XPathContext context) throws XPathException { Controller controller = context.getController(); GroupIterator groupIterator = getGroupIterator(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.setCurrentIterator(groupIterator); c2.setCurrentGroupIterator(groupIterator); c2.setCurrentTemplateRule(null); if (controller.isTracing()) { TraceListener listener = controller.getTraceListener(); while (true) { Item item = groupIterator.next(); if (item == null) { break; } listener.startCurrentItem(item); action.process(c2); listener.endCurrentItem(item); } } else { while (true) { Item item = groupIterator.next(); if (item == null) { break; } action.process(c2); } } return null; }
public TailCall processLeavingTail(XPathContext context) throws XPathException { Controller controller = context.getController(); assert controller != null; PipelineConfiguration pipe = context.getReceiver().getPipelineConfiguration(); GroupIterator groupIterator = getGroupIterator(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); FocusIterator focusIterator = c2.trackFocus(groupIterator); c2.setCurrentGroupIterator(groupIterator); c2.setCurrentTemplateRule(null); pipe.setXPathContext(c2); if (controller.isTracing()) { TraceListener listener = controller.getTraceListener(); assert listener != null; Item item; while ((item = focusIterator.next()) != null) { listener.startCurrentItem(item); getActionExpression().process(c2); listener.endCurrentItem(item); } } else { while (focusIterator.next() != null) { getActionExpression().process(c2); } } pipe.setXPathContext(context); return null; }
public TailCall processLeavingTail(XPathContext context) throws XPathException { Controller controller = context.getController(); assert controller != null; PipelineConfiguration pipe = context.getReceiver().getPipelineConfiguration(); GroupIterator groupIterator = getGroupIterator(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); FocusIterator focusIterator = c2.trackFocus(groupIterator); c2.setCurrentGroupIterator(groupIterator); c2.setCurrentTemplateRule(null); pipe.setXPathContext(c2); if (controller.isTracing()) { TraceListener listener = controller.getTraceListener(); assert listener != null; Item item; while ((item = focusIterator.next()) != null) { listener.startCurrentItem(item); getActionExpression().process(c2); listener.endCurrentItem(item); } } else { while (focusIterator.next() != null) { getActionExpression().process(c2); } } pipe.setXPathContext(context); return null; }
c2.setTunnelParameters(tunnels); c2.openStackFrame(nh.getStackFrameMap()); c2.setCurrentTemplateRule(rule); c2.setCurrentComponent(modeComponent); nh.apply(c2);
c2.setTunnelParameters(tunnels); c2.openStackFrame(nh.getStackFrameMap()); c2.setCurrentTemplateRule(rule); c2.setCurrentComponent(modeComponent); nh.apply(c2);
c2.setOrigin(this); FocusIterator<?> iter = c2.trackFocus(getSelect().iterate(context)); c2.setCurrentTemplateRule(null);