@Override public Sequence<?> evaluate(Expression expr, XPathContext context) throws XPathException { SequenceIterator<?> iter = expr.iterate(context); return iter.materialize(); }
/** * Map one item to a sequence. * * @param context The processing context. The item to be mapped is the context item identified * from this context: the values of position() and last() also relate to the set of items being mapped * @return a SequenceIterator over the sequence of items that the supplied input * item maps to */ public SequenceIterator<?> map(XPathContext context) throws XPathException { return getAction().iterate(context); }
@Override public Sequence<?> evaluate(Expression expr, XPathContext context) throws XPathException { SequenceIterator<?> iter = expr.iterate(context); return new LazySequence<>(iter); }
/** * Map one item to a sequence. * * @param context The processing context. This is supplied only for mapping constructs that * set the context node, position, and size. Otherwise it is null. * @return either (a) a SequenceIterator over the sequence of items that the supplied input * item maps to, or (b) an Item if it maps to a single item, or (c) null if it maps to an empty * sequence. */ public SequenceIterator<?> map(XPathContext context) throws XPathException { return getActionExpression().iterate(context); }
private void makeSequence() throws XPathException { if (sequence == null) { inputIterator = expression.iterate(savedXPathContext); sequence = SequenceTool.toMemoSequence(inputIterator); } }
private List<AtomicValue> getKey(XPathContext context) throws XPathException { List<AtomicValue> key = new ArrayList<>(); SequenceIterator iter = keyExpression.iterate(context); while (true) { AtomicValue val = (AtomicValue) iter.next(); if (val == null) { break; } key.add(val); } return key; }
@Override public Sequence<?> evaluate(Expression expr, XPathContext context) throws XPathException { SequenceIterator<?> iter = expr.iterate(context); return new MemoSequence<>(iter); }
/** * Make a SequenceExtent, given the expected reference count * * @param expression the expression to be evaluated * @param ref the (nominal) number of times the value of the expression is required * @param context the XPath dynamic evaluation context * @return the constructed SequenceExtent * @throws XPathException if evaluation of the expression fails */ public GroundedValue<?> makeSequenceExtent(Expression expression, int ref, XPathContext context) throws XPathException { return expression.iterate(context).materialize(); }
/** * Iterate over the sequence of values */ public SequenceIterator iterate(final XPathContext context) throws XPathException { SequenceIterator base = operand.iterate(context); ItemMappingFunction promoter = new ItemMappingFunction() { public Item map(Item item) throws XPathException { return promote(((AtomicValue)item), context); } }; return new ItemMappingIterator(base, promoter); }
/** * Evaluate the expression giving a boolean result * * @param context the given context for evaluation * @return a boolean representing the result of the comparison of the two operands */ public boolean effectiveBooleanValue(XPathContext context) throws XPathException { return effectiveBooleanValue(getLhsExpression().iterate(context), getRhsExpression().iterate(context), context); }
/** * Evaluate the expression as a boolean */ public boolean effectiveBooleanValue(XPathContext context) throws XPathException { SequenceIterator iter = getBaseExpression().iterate(context); return isInstance(iter, context); }
/** * Iterate over the results of all the child expressions */ public SequenceIterator iterate(XPathContext context) throws XPathException { if (children==null || children.length == 0) { return EmptyIterator.getInstance(); } else if (children.length == 1) { return children[0].iterate(context); } else { return new BlockIterator(children, context); } }
/** * Execute the expression, returning the result as a single {@link net.sf.saxon.om.Item} * If the result of the expression is a sequence containing more than one item, items after * the first are discarded. If the result is an empty sequence, the method returns null. * @param context the XPath dynamic context * @return the first item in the result of the expression, or null */ public Item evaluateSingle(XPathDynamicContext context) throws XPathException { return expression.iterate(context.getXPathContextObject()).next(); }
public GroupStartingIterator(Expression select, Pattern startPattern, XPathContext context) throws XPathException { this.select = select; this.pattern = startPattern; baseContext = context; runningContext = context.newMinorContext(); this.population = runningContext.trackFocus(select.iterate(context)); // the first item in the population always starts a new group next = population.next(); }
/** * Evaluate the expression */ public Item evaluateItem(XPathContext context) throws XPathException { SequenceIterator iter = getBaseExpression().iterate(context); Item result = iter.next(); iter.close(); return result; }
public GroupEndingIterator(Expression select, Pattern endPattern, XPathContext context) throws XPathException { this.select = select; this.pattern = endPattern; baseContext = context; runningContext = context.newMinorContext(); this.population = runningContext.trackFocus(select.iterate(context)); // the first item in the population always starts a new group next = population.next(); }
public SequenceIterator iterate(XPathContext context) throws XPathException { SequenceIterator forwards = argument[0].iterate(context); if (forwards instanceof ReversibleIterator) { return ((ReversibleIterator)forwards).getReverseIterator(); } else { SequenceExtent extent = new SequenceExtent(forwards); return extent.reverseIterate(); } }
/** * Get the effective boolean value. In the case of a union expression, this * is reduced to an OR expression, for efficiency */ @Override public boolean effectiveBooleanValue(XPathContext c) throws XPathException { NodeInfo m = (NodeInfo) getLhsExpression().evaluateItem(c); return m != null && containsNode(getRhsExpression().iterate(c), m); }
/** * Process this expression as an instruction, writing results to the current * outputter */ public void process(XPathContext context) throws XPathException { int slot = getLocalSlotNumber(); getSequence().iterate(context).forEachOrFail(item -> { context.setLocalVariable(slot, item); getAction().process(context); }); }
private SequenceIterator getInputIterator(AtomicComparer[] comps, SequenceIterator inputIterator, MergeSource ms, XPathContext c2) throws XPathException { XPathContext c4 = c2.newMinorContext(); c4.setTemporaryOutputState(StandardNames.XSL_MERGE_KEY); FocusIterator<?> rowIntr = c4.trackFocus(ms.getRowSelect().iterate(c2)); MergeKeyMappingFunction addMergeKeys = new MergeKeyMappingFunction(c4, ms); ContextMappingIterator<ExternalObject<ItemWithMergeKeys>> contextMapKeysItr = new ContextMappingIterator<>(addMergeKeys, c4); inputIterator = makeMergeIterator(inputIterator, comps, ms, contextMapKeysItr); return inputIterator; }