Package net.sf.saxon.trans

## Interface GlobalVariableManager

- All Known Implementing Classes:
    `PrincipalStylesheetModule`, `PrincipalStylesheetModuleEE`

      public interface GlobalVariableManager

  This interface provides access to a collection of global variables. This abstraction is used by the optimizer to handle the rather different ways that global variables are managed in XSLT and XQuery, as a result of XSLT packaging.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addGlobalVariable​(GlobalVariable variable)` | Add a global variable to the collection
    `GlobalVariable` | `getEquivalentVariable​(Expression select)` | Get an existing global variable whose initializer is a given expression, if there is one.

- - ### Method Detail

    - #### getEquivalentVariable

          GlobalVariable getEquivalentVariable​(Expression select)

      Get an existing global variable whose initializer is a given expression, if there is one. Note that this depends on the logic for detecting equivalence of expressions, which is necessarily approximate. Expressions with dependencies on the static context should never be considered equivalent. If no equivalent global variable is found, return null. An implementation can always return null if it wants to avoid a lengthy search.
      Returns:
        an existing global variable with the same select expression, if one can be found; otherwise null.

    - #### addGlobalVariable

          void addGlobalVariable​(GlobalVariable variable)
                          throws XPathException

      Add a global variable to the collection
      Parameters:
        `variable` - the variable to be added
      Throws:
        `XPathException` - if errors occur (some implementations of the method have side-effects, such as causing the variable declaration to be compiled)