| 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 | /** |
| 17 | * Implements the XSLT function current-grouping-key() |
| 18 | */ |
| 19 | |
| 20 | public class CurrentGroupingKey extends SystemFunction { |
| 21 | |
| 22 | /** |
| 23 | * Make an expression that either calls this function, or that is equivalent to a call |
| 24 | * on this function |
| 25 | * |
| 26 | * @param arguments the supplied arguments to the function call |
| 27 | * @return either a function call on this function, or an expression that delivers |
| 28 | * the same result |
| 29 | */ |
| 30 | @Override |
| 31 | public Expression makeFunctionCall(Expression... arguments) { |
| 32 | return new CurrentGroupingKeyCall(); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Evaluate the expression |
| 37 | * |
| 38 | * @param context the dynamic evaluation context |
| 39 | * @param arguments the values of the arguments, supplied as SequenceIterators |
| 40 | * @return the result of the evaluation, in the form of a SequenceIterator |
| 41 | * @throws net.sf.saxon.trans.XPathException |
| 42 | * if a dynamic error occurs during the evaluation of the expression |
| 43 | */ |
| 44 | public Sequence<?> call(XPathContext context, Sequence[] arguments) throws XPathException { |
| 45 | throw new XPathException("Dynamic call on current-grouping-key() fails (the current group is absent)", "XTDE1071"); |
| 46 | } |
| 47 | |
| 48 | } |
| 49 |