public MappingIterator.StatefulMappingFunction getAnother() { // Create a copy of the stack frame, so that changes made to local variables by the cloned // iterator are not seen by the original iterator XPathContextMajor c2 = context.newContext(); StackFrame oldstack = context.getStackFrame(); ValueRepresentation[] vars = oldstack.getStackFrameValues(); ValueRepresentation[] newvars = new ValueRepresentation[vars.length]; System.arraycopy(vars, 0, newvars, 0, vars.length); c2.setStackFrame(oldstack.getStackFrameMap(), newvars); return new MappingAction(c2, slotNumber, pslot, action); } }
/** * Call this function in "push" mode, writing the results to the current output destination. * @param actualArgs the arguments supplied to the function. These must have the correct * types required by the function signature (it is the caller's responsibility to check this). * It is acceptable to supply a {@link net.sf.saxon.value.Closure} to represent a value whose * evaluation will be delayed until it is needed. The array must be the correct size to match * the number of arguments: again, it is the caller's responsibility to check this. * @param context This provides the run-time context for evaluating the function. It is the caller's * responsibility to allocate a "clean" context for the function to use; the context that is provided * will be overwritten by the function. */ public void process(ValueRepresentation[] actualArgs, XPathContextMajor context) throws XPathException { context.setStackFrame(getStackFrameMap(), actualArgs); getBody().process(context); }
/** * Call this function in "pull" mode, returning the results as a sequence of PullEvents. * @param actualArgs the arguments supplied to the function. These must have the correct * types required by the function signature (it is the caller's responsibility to check this). * It is acceptable to supply a {@link net.sf.saxon.value.Closure} to represent a value whose * evaluation will be delayed until it is needed. The array must be the correct size to match * the number of arguments: again, it is the caller's responsibility to check this. * @param context This provides the run-time context for evaluating the function. It is the caller's * responsibility to allocate a "clean" context for the function to use; the context that is provided * will be overwritten by the function. * @return an iterator over the results of the function call */ public EventIterator iterateEvents(ValueRepresentation[] actualArgs, XPathContextMajor context) throws XPathException { context.setStackFrame(getStackFrameMap(), actualArgs); return getBody().iterateEvents(context); }
public StatefulMappingFunction getAnother() { // Create a copy of the stack frame, so that changes made to local variables by the cloned // iterator are not seen by the original iterator XPathContextMajor c2 = context.newContext(); StackFrame oldstack = context.getStackFrame(); Sequence[] vars = oldstack.getStackFrameValues(); Sequence[] newvars = Arrays.copyOf(vars, vars.length); c2.setStackFrame(oldstack.getStackFrameMap(), newvars); return new MappingAction(c2, slotNumber, action); } }
/** * Call this function in "push" mode, writing the results to the current output destination. * @param actualArgs the arguments supplied to the function. These must have the correct * types required by the function signature (it is the caller's responsibility to check this). * It is acceptable to supply a {@link net.sf.saxon.value.Closure} to represent a value whose * evaluation will be delayed until it is needed. The array must be the correct size to match * the number of arguments: again, it is the caller's responsibility to check this. * @param context This provides the run-time context for evaluating the function. It is the caller's * responsibility to allocate a "clean" context for the function to use; the context that is provided * will be overwritten by the function. */ public void process(ValueRepresentation[] actualArgs, XPathContextMajor context) throws XPathException { context.setStackFrame(getStackFrameMap(), actualArgs); getBody().process(context); }
/** * Call this function in "push" mode, writing the results to the current output destination. * * @param actualArgs the arguments supplied to the function. These must have the correct * types required by the function signature (it is the caller's responsibility to check this). * It is acceptable to supply a {@link net.sf.saxon.value.Closure} to represent a value whose * evaluation will be delayed until it is needed. The array must be the correct size to match * the number of arguments: again, it is the caller's responsibility to check this. * @param context This provides the run-time context for evaluating the function. It is the caller's * responsibility to allocate a "clean" context for the function to use; the context that is provided * will be overwritten by the function. * @throws net.sf.saxon.trans.XPathException if a dynamic error occurs while evaluating the function */ public void process(Sequence[] actualArgs, XPathContextMajor context) throws XPathException { context.setStackFrame(getStackFrameMap(), actualArgs); getBody().process(context); }
public StatefulMappingFunction getAnother() { // Create a copy of the stack frame, so that changes made to local variables by the cloned // iterator are not seen by the original iterator XPathContextMajor c2 = context.newContext(); StackFrame oldstack = context.getStackFrame(); ValueRepresentation[] vars = oldstack.getStackFrameValues(); ValueRepresentation[] newvars = new ValueRepresentation[vars.length]; System.arraycopy(vars, 0, newvars, 0, vars.length); c2.setStackFrame(oldstack.getStackFrameMap(), newvars); return new MappingAction(c2, slotNumber, pslot, action); } }
public MappingIterator.StatefulMappingFunction getAnother() { // Create a copy of the stack frame, so that changes made to local variables by the cloned // iterator are not seen by the original iterator XPathContextMajor c2 = context.newContext(); StackFrame oldstack = context.getStackFrame(); ValueRepresentation[] vars = oldstack.getStackFrameValues(); ValueRepresentation[] newvars = new ValueRepresentation[vars.length]; System.arraycopy(vars, 0, newvars, 0, vars.length); c2.setStackFrame(oldstack.getStackFrameMap(), newvars); return new MappingAction(c2, slotNumber, pslot, action); } }
/** * Call this function in "pull" mode, returning the results as a sequence of PullEvents. * @param actualArgs the arguments supplied to the function. These must have the correct * types required by the function signature (it is the caller's responsibility to check this). * It is acceptable to supply a {@link net.sf.saxon.value.Closure} to represent a value whose * evaluation will be delayed until it is needed. The array must be the correct size to match * the number of arguments: again, it is the caller's responsibility to check this. * @param context This provides the run-time context for evaluating the function. It is the caller's * responsibility to allocate a "clean" context for the function to use; the context that is provided * will be overwritten by the function. * @return an iterator over the results of the function call */ public EventIterator iterateEvents(ValueRepresentation[] actualArgs, XPathContextMajor context) throws XPathException { context.setStackFrame(getStackFrameMap(), actualArgs); return getBody().iterateEvents(context); }
/** * Call this function in "push" mode, writing the results to the current output destination. * * @param actualArgs the arguments supplied to the function. These must have the correct * types required by the function signature (it is the caller's responsibility to check this). * It is acceptable to supply a {@link net.sf.saxon.value.Closure} to represent a value whose * evaluation will be delayed until it is needed. The array must be the correct size to match * the number of arguments: again, it is the caller's responsibility to check this. * @param context This provides the run-time context for evaluating the function. It is the caller's * responsibility to allocate a "clean" context for the function to use; the context that is provided * will be overwritten by the function. * @throws net.sf.saxon.trans.XPathException if a dynamic error occurs while evaluating the function */ public void process(Sequence[] actualArgs, XPathContextMajor context) throws XPathException { context.setStackFrame(getStackFrameMap(), actualArgs); getBody().process(context); }
/** * Call an updating function. * @param actualArgs the arguments supplied to the function. These must have the correct * types required by the function signature (it is the caller's responsibility to check this). * It is acceptable to supply a {@link net.sf.saxon.value.Closure} to represent a value whose * evaluation will be delayed until it is needed. The array must be the correct size to match * the number of arguments: again, it is the caller's responsibility to check this. * @param context the dynamic evaluation context * @param pul the pending updates list, to which the function's update actions are to be added. */ public void callUpdating(ValueRepresentation[] actualArgs, XPathContextMajor context, PendingUpdateList pul) throws XPathException { context.setStackFrame(getStackFrameMap(), actualArgs); try { getBody().evaluatePendingUpdates(context, pul); } catch (XPathException err) { err.maybeSetLocation(this); throw err; } }
/** * Call an updating function. * * @param actualArgs the arguments supplied to the function. These must have the correct * types required by the function signature (it is the caller's responsibility to check this). * It is acceptable to supply a {@link net.sf.saxon.value.Closure} to represent a value whose * evaluation will be delayed until it is needed. The array must be the correct size to match * the number of arguments: again, it is the caller's responsibility to check this. * @param context the dynamic evaluation context * @param pul the pending updates list, to which the function's update actions are to be added. * @throws net.sf.saxon.trans.XPathException if a dynamic error occurs while evaluating the function. */ public void callUpdating(Sequence[] actualArgs, XPathContextMajor context, PendingUpdateList pul) throws XPathException { context.setStackFrame(getStackFrameMap(), actualArgs); try { getBody().evaluatePendingUpdates(context, pul); } catch (XPathException err) { err.maybeSetLocation(getLocation()); throw err; } }
/** * Call an updating function. * * @param actualArgs the arguments supplied to the function. These must have the correct * types required by the function signature (it is the caller's responsibility to check this). * It is acceptable to supply a {@link net.sf.saxon.value.Closure} to represent a value whose * evaluation will be delayed until it is needed. The array must be the correct size to match * the number of arguments: again, it is the caller's responsibility to check this. * @param context the dynamic evaluation context * @param pul the pending updates list, to which the function's update actions are to be added. * @throws net.sf.saxon.trans.XPathException if a dynamic error occurs while evaluating the function. */ public void callUpdating(Sequence[] actualArgs, XPathContextMajor context, PendingUpdateList pul) throws XPathException { context.setStackFrame(getStackFrameMap(), actualArgs); try { getBody().evaluatePendingUpdates(context, pul); } catch (XPathException err) { err.maybeSetLocation(getLocation()); throw err; } }
/** * Build a data structure containing the values of the accumulator for each node in a document. * The data structure holds the value for all nodes where the value changes; the value for other * nodes is obtained by interpolation * * @param doc the root of the tree for which the accumulator is to be evaluated * @param context the dynamic evaluation context * @throws XPathException if a dynamic error occurs while evaluating the accumulator */ public void buildIndex(NodeInfo doc, XPathContext context) throws XPathException { //System.err.println("Building accData " + this); if (building) { throw new XPathException("Accumulator " + accumulator.getAccumulatorName().getDisplayName() + " requires access to its own value", "XTDE3400"); } building = true; Expression initialValue = accumulator.getInitialValueExpression(); XPathContextMajor c2 = context.newContext(); SlotManager sf = accumulator.getSlotManagerForInitialValueExpression(); Sequence[] slots = new Sequence[sf.getNumberOfVariables()]; c2.setStackFrame(sf, slots); c2.setCurrentIterator(new ManualIterator<>(doc)); Sequence<?> val = initialValue.iterate(c2).materialize(); values.add(new DataPoint(new Visit(doc, false), val)); val = visit(doc, val, c2); values.add(new DataPoint(new Visit(doc, true), val)); ((ArrayList) values).trimToSize(); building = false; //diagnosticPrint(); }
/** * Build a data structure containing the values of the accumulator for each node in a document. * The data structure holds the value for all nodes where the value changes; the value for other * nodes is obtained by interpolation * * @param doc the root of the tree for which the accumulator is to be evaluated * @param context the dynamic evaluation context * @throws XPathException if a dynamic error occurs while evaluating the accumulator */ public void buildIndex(NodeInfo doc, XPathContext context) throws XPathException { //System.err.println("Building accData " + this); if (building) { throw new XPathException("Accumulator " + accumulator.getAccumulatorName().getDisplayName() + " requires access to its own value", "XTDE3400"); } building = true; Expression initialValue = accumulator.getInitialValueExpression(); XPathContextMajor c2 = context.newContext(); SlotManager sf = accumulator.getSlotManagerForInitialValueExpression(); Sequence[] slots = new Sequence[sf.getNumberOfVariables()]; c2.setStackFrame(sf, slots); c2.setCurrentIterator(new ManualIterator<>(doc)); Sequence<?> val = initialValue.iterate(c2).materialize(); values.add(new DataPoint(new Visit(doc, false), val)); val = visit(doc, val, c2); values.add(new DataPoint(new Visit(doc, true), val)); ((ArrayList) values).trimToSize(); building = false; //diagnosticPrint(); }
context.setStackFrame(getStackFrameMap(), actualArgs); ValueRepresentation result; try {
c2.setStackFrame(getStackFrameMap(), actualArgs); Sequence<?> result; try {
c2.setStackFrame(getStackFrameMap(), actualArgs); Sequence<?> result; try {
ValueRepresentation[] savedStackFrame = new ValueRepresentation[local.length]; System.arraycopy(local, 0, savedStackFrame, 0, local.length); savedXPathContext.setStackFrame(localStackFrame.getStackFrameMap(), savedStackFrame);
savedXPathContext.setStackFrame(stackFrameMap, savedStackFrame);