/** * Get the next item from one of the input sequences, * checking that it is a node. * * @param iter the iterator from which the next item is to be taken * @return the next value returned by that iterator * @throws XPathException if a failure occurs reading from the input sequence */ private NodeInfo next(SequenceIterator<? extends NodeInfo> iter) throws XPathException { return iter.next(); // rely on type-checking to prevent a ClassCastException }
/** * Get the next item from one of the input sequences, * checking that it is a node. * * @param iter the sequence from which a node is to be read * @return the node that was read * @throws XPathException if reading from either of the input sequences fails */ private NodeInfo next(SequenceIterator iter) throws XPathException { return (NodeInfo) iter.next(); // we rely on the type-checking mechanism to prevent a ClassCastException here }
/** * Create an iterator which filters an input sequence to select only those nodes * that have no ancestor in the sequence * * @param in the input sequence, which must be a sequence of nodes in document order with no duplicates * @throws XPathException if an error occurs evaluating the input iterator */ public InnermostIterator(SequenceIterator<? extends NodeInfo> in) throws XPathException { this.in = in; pending = in.next(); }
/** * Get the first item in the sequence. This calls iterate() internally, which means it can only * be called once; the method should only be used if the client requires only the first item in * the sequence (or knows that the sequence has length one). * @return the first item, or null if the sequence is empty * @throws XPathException if an error occurs evaluating the underlying expression */ public T head() throws XPathException { return iterate().next(); }
public MergeGroupingIterator( SequenceIterator p1, ItemOrderComparer comp, LastPositionFinder lpf) throws XPathException { this.baseItr = p1; next = (ObjectValue<ItemWithMergeKeys>)p1.next(); if (next != null) { compositeMergeKey = ((ItemWithMergeKeys) ((ObjectValue) next).getObject()).sortKeyValues; } this.comparer = comp; this.lastPositionFinder = lpf; }
public AtomicValue next() throws XPathException { Item nextSource = base.next(); if (nextSource == null) { return null; } else { return (AtomicValue) nextSource.atomize(); } }
/** * Get the first item in the sequence. * * @return the first item in the sequence if there is one, or null if the sequence * is empty * @throws net.sf.saxon.trans.XPathException * in the situation where the sequence is evaluated lazily, and * evaluation of the first item causes a dynamic error. */ public Item<?> head() throws XPathException { return iterate().next(); }
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; }
public Item next() throws XPathException { Item nextSource = base.next(); if (nextSource == null) { return null; } // Call the supplied mapping function return action.mapItem(nextSource); }
/** * Evaluate as a singleton item (or empty sequence). Note: this implementation returns * the first item in the sequence. The method should not be used unless appropriate type-checking * has been done to ensure that the value will be a singleton. */ public Item evaluateItem(XPathContext context) throws XPathException { if (value instanceof AtomicValue) { return (AtomicValue)value; } return value.iterate().next(); }
private String toSpaceSeparatedString(Sequence<?> seqVal) throws XPathException { SequenceIterator<?> iterator = seqVal.iterate(); Item item; StringBuilder stringVal = new StringBuilder(); while ((item = iterator.next()) != null) { stringVal.append(" ").append(item.getStringValue()); } return stringVal.toString(); }
/** * Determine whether two node-sets contain at least one node in common * @param p1 The first node-set * @param p2 The second node-set * @return true if p1 and p2 contain at least one node in common (i.e. if the intersection * is not empty) */ public static boolean hasSameNode(SequenceIterator p1, SequenceIterator p2) throws XPathException { SequenceIterator intersection = new IntersectionEnumeration(p1, p2, GlobalOrderComparer.getInstance()); return intersection.next() != null; }
public GroupEndingIterator(SequenceIterator population, Pattern endPattern, XPathContext context) throws XPathException { this.population = population; this.endPattern = endPattern; baseContext = context; runningContext = context.newMinorContext(); runningContext.setCurrentIterator(population); // the first item in the population always starts a new group next = population.next(); }
private static boolean empty(SequenceIterator iter) throws XPathException { boolean result; if ((iter.getProperties() & SequenceIterator.LOOKAHEAD) != 0) { result = !((LookaheadIterator) iter).hasNext(); } else { result = iter.next() == null; } iter.close(); return result; }
public MapItem call(XPathContext context, Sequence[] arguments) throws XPathException { MapItem map = (MapItem) arguments[0].head(); SequenceIterator iter = arguments[1].iterate(); AtomicValue key; while ((key = (AtomicValue) iter.next()) != null) { map = map.remove(key); } return map; }
private static boolean exists(SequenceIterator iter) throws XPathException { boolean result; if ((iter.getProperties() & SequenceIterator.LOOKAHEAD) != 0) { result = ((LookaheadIterator) iter).hasNext(); } else { result = iter.next() != null; } iter.close(); return result; }
public static void copySequence(SequenceIterator in, SequenceReceiver out) throws XPathException { out.open(); while (true) { Item item = in.next(); if (item == null) { break; } out.append(item, 0, NodeInfo.ALL_NAMESPACES); } out.close(); } }
public T next() throws XPathException { try { return base.next(); } catch (XPathException e1) { e1.maybeSetLocation(expression.getLocation()); listener.fatalError(e1); e1.setHasBeenReported(true); throw e1; } }
private void checkSequenceIsUntyped(Sequence value) throws XPathException { SequenceIterator iter = value.iterate(); Item item; while ((item = iter.next()) != null) { if (item instanceof NodeInfo && ((NodeInfo) item).getTreeInfo().isTyped()) { throw new XPathException("Schema-validated nodes cannot be passed to fn:transform() when it runs under a different Saxon Configuration", "FOXT0002"); } } }