| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.functions; |
| 9 | |
| 10 | import net.sf.saxon.expr.Expression; |
| 11 | import net.sf.saxon.expr.XPathContext; |
| 12 | import net.sf.saxon.om.Sequence; |
| 13 | import net.sf.saxon.trans.XPathException; |
| 14 | |
| 15 | /** |
| 16 | * Implements the XSLT function current-group() |
| 17 | */ |
| 18 | |
| 19 | public class CurrentGroup extends SystemFunction { |
| 20 | |
| 21 | /** |
| 22 | * Make an expression that either calls this function, or that is equivalent to a call |
| 23 | * on this function |
| 24 | * |
| 25 | * @param arguments the supplied arguments to the function call |
| 26 | * @return either a function call on this function, or an expression that delivers |
| 27 | * the same result |
| 28 | */ |
| 29 | @Override |
| 30 | public Expression makeFunctionCall(Expression... arguments) { |
| 31 | return new CurrentGroupCall(); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Evaluate the expression |
| 36 | * |
| 37 | * @param context the dynamic evaluation context |
| 38 | * @param arguments the values of the arguments, supplied as SequenceIterators |
| 39 | * @return the result of the evaluation, in the form of a SequenceIterator |
| 40 | * @throws net.sf.saxon.trans.XPathException |
| 41 | * if a dynamic error occurs during the evaluation of the expression |
| 42 | */ |
| 43 | public Sequence<?> call(XPathContext context, Sequence[] arguments) throws XPathException { |
| 44 | throw new XPathException("Dynamic call on current-group() fails (the current group is absent)", "XTDE1061"); |
| 45 | } |
| 46 | |
| 47 | } |
| 48 |