| 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.trans; |
| 9 | |
| 10 | import net.sf.saxon.expr.Expression; |
| 11 | import net.sf.saxon.expr.instruct.GlobalVariable; |
| 12 | |
| 13 | /** |
| 14 | * This interface provides access to a collection of global variables. This abstraction is used by the optimizer |
| 15 | * to handle the rather different ways that global variables are managed in XSLT and XQuery, as a result of |
| 16 | * XSLT packaging. |
| 17 | */ |
| 18 | |
| 19 | public interface GlobalVariableManager { |
| 20 | |
| 21 | /** |
| 22 | * Get an existing global variable whose initializer is a given expression, |
| 23 | * if there is one. Note that this depends on the logic for detecting equivalence |
| 24 | * of expressions, which is necessarily approximate. Expressions with dependencies |
| 25 | * on the static context should never be considered equivalent. If no equivalent global |
| 26 | * variable is found, return null. An implementation can always return null if |
| 27 | * it wants to avoid a lengthy search. |
| 28 | * @return an existing global variable with the same select expression, if one |
| 29 | * can be found; otherwise null. |
| 30 | */ |
| 31 | |
| 32 | GlobalVariable getEquivalentVariable(Expression select); |
| 33 | |
| 34 | /** |
| 35 | * Add a global variable to the collection |
| 36 | * @param variable the variable to be added |
| 37 | * @throws XPathException if errors occur (some implementations of the method have side-effects, |
| 38 | * such as causing the variable declaration to be compiled) |
| 39 | */ |
| 40 | |
| 41 | void addGlobalVariable(GlobalVariable variable) throws XPathException; |
| 42 | |
| 43 | } |
| 44 | |
| 45 | // Copyright (c) 2018 Saxonica Limited. |
| 46 |