public SequenceIterator getAnother() throws XPathException { SequenceIterator newBase = base.getAnother(); MappingFunction newAction = action; if (newAction instanceof StatefulMappingFunction) { newAction = ((StatefulMappingFunction)newAction).getAnother(); } return new MappingIterator(newBase, newAction); }
/** * Get an iterator that returns the result of atomizing the sequence delivered by the supplied * iterator * @param base the supplied iterator, the input to atomization * @return an iterator that returns atomic values, the result of the atomization */ public static SequenceIterator getAtomizingIterator(SequenceIterator base) { if (base instanceof AxisIterator) { return new AxisAtomizingIterator((AxisIterator)base); } return new MappingIterator(base, AtomizingFunction.getInstance()); }
/** * Get an iterator that returns the result of atomizing the sequence delivered by the supplied * iterator * @param base the supplied iterator, the input to atomization * @return an iterator that returns atomic values, the result of the atomization */ public static SequenceIterator getAtomizingIterator(SequenceIterator base) { if (base instanceof AxisIterator) { return new AxisAtomizingIterator((AxisIterator)base); } return new MappingIterator(base, AtomizingFunction.getInstance()); }
public SequenceIterator getAnother() throws XPathException { SequenceIterator newBase = base.getAnother(); MappingFunction newAction = action instanceof StatefulMappingFunction ? ((StatefulMappingFunction)action).getAnother() : action; return new MappingIterator(newBase, newAction); }
/** * Get an iterator that returns the result of atomizing the sequence delivered by the supplied * iterator * @param base the supplied iterator, the input to atomization * @return an iterator that returns atomic values, the result of the atomization */ public static SequenceIterator getAtomizingIterator(SequenceIterator base) { if (base instanceof AxisIterator) { return new AxisAtomizingIterator((AxisIterator)base); } return new MappingIterator(base, AtomizingFunction.getInstance()); }
/** * Get the typed value of a given input string. This method assumes that the input value * is valid according to this SimpleType * @param value the string whose typed value is required * @param resolver namespace resolver for namespace-sensitive content * @param nameChecker name checker for XML-version sensitive content */ public SequenceIterator getTypedValue(CharSequence value, NamespaceResolver resolver, NameChecker nameChecker) throws ValidationException { UnfailingIterator iter = new StringTokenIterator(value.toString()); ListTypeMappingFunction map = new ListTypeMappingFunction(); map.resolver = resolver; map.atomicType = (AtomicType)getItemType(); map.nameChecker = nameChecker; return new MappingIterator(iter, map); }
/** * Get the typed value of a given input string. This method assumes that the input value * is valid according to this SimpleType * @param value the string whose typed value is required * @param resolver namespace resolver for namespace-sensitive content * @param nameChecker name checker for XML-version sensitive content */ public SequenceIterator getTypedValue(CharSequence value, NamespaceResolver resolver, NameChecker nameChecker) throws ValidationException { UnfailingIterator iter = new StringTokenIterator(value.toString()); ListTypeMappingFunction map = new ListTypeMappingFunction(); map.resolver = resolver; map.atomicType = (AtomicType)getItemType(); map.nameChecker = nameChecker; return new MappingIterator(iter, map); }
public SequenceIterator iterate(XPathContext context) throws XPathException { SequenceIterator iter = new SortedTupleIterator(context, select.iterate(context), comparators); return new MappingIterator(iter, TupleUnwrapper.getInstance()); }
public SequenceIterator iterate(XPathContext context) throws XPathException { SequenceIterator iter = new SortedTupleIterator(context, select.iterate(context), comparators); return new MappingIterator(iter, TupleUnwrapper.getInstance()); }
/** * Get an iterator over the nodes that have an id equal to one of the values is a set of whitespace separated * strings * @param doc The document to be searched * @param idrefs an iterator over a set of strings each of which is a string containing * zero or more whitespace-separated ID values to be found in the document * @return an iterator over the nodes whose ID is one of the specified values * @throws XPathException */ public static SequenceIterator getIdMultiple(DocumentInfo doc, SequenceIterator idrefs) throws XPathException { IdMappingFunction map = new IdMappingFunction(); map.document = doc; SequenceIterator result = new MappingIterator(idrefs, map); return new DocumentOrderIterator(result, LocalOrderComparer.getInstance()); }
/** * Get an iterator over the nodes that have an id equal to one of the values is a set of whitespace separated * strings * @param doc The document to be searched * @param idrefs an iterator over a set of strings each of which is a string containing * zero or more whitespace-separated ID values to be found in the document * @return an iterator over the nodes whose ID is one of the specified values * @throws XPathException */ public static SequenceIterator getIdMultiple(DocumentInfo doc, SequenceIterator idrefs) throws XPathException { IdMappingFunction map = new IdMappingFunction(); map.document = doc; SequenceIterator result = new MappingIterator(idrefs, map); return new DocumentOrderIterator(result, LocalOrderComparer.getInstance()); }
/** * Get an iterator over the nodes that have an id equal to one of the values is a set of whitespace separated * strings * @param doc The document to be searched * @param idrefs an iterator over a set of strings each of which is a string containing * zero or more whitespace-separated ID values to be found in the document * @return an iterator over the nodes whose ID is one of the specified values * @throws XPathException */ public static SequenceIterator getIdMultiple(DocumentInfo doc, SequenceIterator idrefs) throws XPathException { IdMappingFunction map = new IdMappingFunction(); map.document = doc; SequenceIterator result = new MappingIterator(idrefs, map); return new DocumentOrderIterator(result, LocalOrderComparer.getInstance()); }
/** * Get an iterator over the nodes that have an id equal to one of the values is a set of whitespace separated * strings * * @param doc The document to be searched * @param idrefs an iterator over a set of strings each of which is a string containing * zero or more whitespace-separated ID values to be found in the document * @param operation distinguishes id() and element-with-id() * @return an iterator over the nodes whose ID is one of the specified values * @throws XPathException if an error occurs */ public static SequenceIterator getIdMultiple( TreeInfo doc, SequenceIterator<?> idrefs, int operation) throws XPathException { IdMappingFunction map = new IdMappingFunction(); map.document = doc; map.operation = operation; SequenceIterator<?> result = new MappingIterator<>(idrefs, map); return new DocumentOrderIterator(result, LocalOrderComparer.getInstance()); }
/** * Iterate over the sequence of values */ public SequenceIterator iterate(XPathContext context) throws XPathException { // First create an iteration of the base sequence. // Then create a MappingIterator which applies a mapping function to each // item in the base sequence. The mapping function is essentially the "return" // expression, wrapped in a MappingAction object that is responsible also for // setting the range variable at each step. SequenceIterator base = sequence.iterate(context); int pslot = (positionVariable == null ? -1 : positionVariable.getLocalSlotNumber()); MappingFunction map = new MappingAction(context, getLocalSlotNumber(), pslot, action); return new MappingIterator(base, map); }
/** * Iterate over the sequence of values */ public SequenceIterator iterate(XPathContext context) throws XPathException { // First create an iteration of the base sequence. // Then create a MappingIterator which applies a mapping function to each // item in the base sequence. The mapping function is essentially the "return" // expression, wrapped in a MappingAction object that is responsible also for // setting the range variable at each step. SequenceIterator base = sequence.iterate(context); int pslot = (positionVariable == null ? -1 : positionVariable.getLocalSlotNumber()); MappingFunction map = new MappingAction(context, getLocalSlotNumber(), pslot, action); return new MappingIterator(base, map); }
/** * Iterate over the sequence of values */ public SequenceIterator iterate(XPathContext context) throws XPathException { // First create an iteration of the base sequence. // Then create a MappingIterator which applies a mapping function to each // item in the base sequence. The mapping function is essentially the "return" // expression, wrapped in a MappingAction object that is responsible also for // setting the range variable at each step. SequenceIterator base = sequence.iterate(context); int pslot = (positionVariable == null ? -1 : positionVariable.getLocalSlotNumber()); MappingFunction map = new MappingAction(context, getLocalSlotNumber(), pslot, action); return new MappingIterator(base, map); }
/** * Get the result when multiple idref values are supplied. Note this is also called from * compiled XQuery code. * @param doc the document to be searched * @param keys the idref values supplied * @param context the dynamic execution context * @return iterator over the result of the function * @throws XPathException */ public static SequenceIterator getIdrefMultiple(DocumentInfo doc, SequenceIterator keys, XPathContext context) throws XPathException { IdrefMappingFunction map = new IdrefMappingFunction(); map.document = doc; map.keyContext = context; map.keyManager = context.getController().getKeyManager(); map.keySet = map.keyManager.getKeyDefinitionSet(StandardNames.getStructuredQName(StandardNames.XS_IDREFS)); SequenceIterator allValues = new MappingIterator(keys, map); return new DocumentOrderIterator(allValues, LocalOrderComparer.getInstance()); }
/** * Evaluate the function for a single string value * (implements the MappingFunction interface) */ public SequenceIterator<?> map(Item item) { String idrefs = Whitespace.trim(item.getStringValueCS()); // If this value contains a space, we need to break it up into its // separate tokens; if not, we can process it directly if (Whitespace.containsWhitespace(idrefs)) { Whitespace.Tokenizer tokens = new Whitespace.Tokenizer(idrefs); IdMappingFunction submap = new IdMappingFunction(); submap.document = document; submap.operation = operation; return new MappingIterator<>(tokens, submap); } else { return SingletonIterator.makeIterator(document.selectID(idrefs, operation == ELEMENT_WITH_ID)); } } }
/** * Iterate the path-expression in a given context * * @param context the evaluation context */ /*@NotNull*/ public SequenceIterator<?> iterate(final XPathContext context) throws XPathException { // This class delivers the result of the path expression in unsorted order, // without removal of duplicates. If sorting and deduplication are needed, // this is achieved by wrapping the path expression in a DocumentSorter if (contextFree) { return new MappingIterator<>( getStart().iterate(context), (MappingFunction<Item<?>, NodeInfo>) item -> ((AxisExpression) getRhsExpression()).iterate((NodeInfo)item)); } XPathContext context2 = context.newMinorContext(); context2.trackFocus(getStart().iterate(context)); return new ContextMappingIterator<Item<?>>(c1 -> getStep().iterate(c1), context2); }
/** * Iterate over the result of the expression */ /*@NotNull*/ public SequenceIterator<?> iterate(XPathContext context) throws XPathException { // First create an iteration of the base sequence. // Then create a MappingIterator which applies a mapping function to each // item in the base sequence. The mapping function is essentially the "return" // expression, wrapped in a MappingAction object that is responsible also for // setting the range variable at each step. SequenceIterator base = getSequence().iterate(context); LookaheadIterator ahead = LookaheadIteratorImpl.makeLookaheadIterator(base); if (ahead.hasNext()) { MappingFunction map = new MappingAction(context, getLocalSlotNumber(), getAction()); return new MappingIterator(ahead, map); } else { context.setLocalVariable(getLocalSlotNumber(), EmptySequence.getInstance()); return getAction().iterate(context); } }