/** * 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 handles iteration for expressions that * return singleton values: for non-singleton expressions, the subclass must * provide its own implementation. * * @param context supplies the context for evaluation * @return a SequenceIterator that can be used to iterate over the result * of the expression * @throws net.sf.saxon.trans.XPathException if any dynamic error occurs evaluating the * expression */ @Override public SequenceIterator<?> iterate(XPathContext context) throws XPathException { Function target = getTargetFunction(context); Sequence[] actualArgs = evaluateArguments(context); try { return target.call(context, actualArgs).iterate(); } catch (XPathException e) { e.maybeSetLocation(getLocation()); e.maybeSetContext(context); e.maybeSetFailingExpression(this); throw e; } }
/** * 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 handles iteration for expressions that * return singleton values: for non-singleton expressions, the subclass must * provide its own implementation. * * @param context supplies the context for evaluation * @return a SequenceIterator that can be used to iterate over the result * of the expression * @throws net.sf.saxon.trans.XPathException if any dynamic error occurs evaluating the * expression */ @Override public SequenceIterator<?> iterate(XPathContext context) throws XPathException { Function target = getTargetFunction(context); Sequence[] actualArgs = evaluateArguments(context); try { return target.call(context, actualArgs).iterate(); } catch (XPathException e) { e.maybeSetLocation(getLocation()); e.maybeSetContext(context); e.maybeSetFailingExpression(this); throw e; } }
/** * Check number of arguments. <BR> * A convenience routine for use in subclasses. * * @param min the minimum number of arguments allowed * @param max the maximum number of arguments allowed * @return the actual number of arguments * @throws net.sf.saxon.trans.XPathException if the number of arguments is out of range */ protected int checkArgumentCount(int min, int max) throws XPathException { int numArgs = getArity(); String msg = null; if (min == max && numArgs != min) { msg = "Function " + getDisplayName() + " must have " + pluralArguments(min); } else if (numArgs < min) { msg = "Function " + getDisplayName() + " must have at least " + pluralArguments(min); } else if (numArgs > max) { msg = "Function " + getDisplayName() + " must have no more than " + pluralArguments(max); } if (msg != null) { XPathException err = new XPathException(msg, "XPST0017"); err.setIsStaticError(true); err.setLocation(getLocation()); throw err; } return numArgs; }
/** * Check number of arguments. <BR> * A convenience routine for use in subclasses. * * @param min the minimum number of arguments allowed * @param max the maximum number of arguments allowed * @return the actual number of arguments * @throws net.sf.saxon.trans.XPathException if the number of arguments is out of range */ protected int checkArgumentCount(int min, int max) throws XPathException { int numArgs = getArity(); String msg = null; if (min == max && numArgs != min) { msg = "Function " + getDisplayName() + " must have " + pluralArguments(min); } else if (numArgs < min) { msg = "Function " + getDisplayName() + " must have at least " + pluralArguments(min); } else if (numArgs > max) { msg = "Function " + getDisplayName() + " must have no more than " + pluralArguments(max); } if (msg != null) { XPathException err = new XPathException(msg, "XPST0017"); err.setIsStaticError(true); err.setLocation(getLocation()); throw err; } return numArgs; }