## net.sf.saxon.instruct
Class GlobalVariable

    java.lang.Object
      net.sf.saxon.expr.Expression
          net.sf.saxon.instruct.Instruction
              net.sf.saxon.instruct.GeneralVariable
                  net.sf.saxon.instruct.GlobalVariable

All Implemented Interfaces:
  Serializable, SourceLocator, Binding, Container, EvaluableItem, SequenceIterable, TailCallReturner, InstructionInfoProvider

Direct Known Subclasses:
  GlobalParam

    public class GlobalVariable

extends GeneralVariable

A compiled global variable in a stylesheet or query.

See Also:
  Serialized Form

Field Summary

Fields inherited from class net.sf.saxon.expr.Expression
`EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD`

Constructor Summary
`GlobalVariable()`

Method Summary
`ValueRepresentation` `evaluateVariable(XPathContext context)` Evaluate the variable
`Executable` `getExecutable()` Get the executable containing this expression
`int` `getHostLanguage()` Get the host language (XSLT, XQuery, XPath) used to implement the code in this container
`InstructionInfo` `getInstructionInfo()` Get InstructionInfo for this expression
`ValueRepresentation` `getSelectValue(XPathContext context)` Evaluate the variable.
`boolean` `isGlobal()` Is this a global variable?
`void` `lookForCycles(Stack referees)` Check for cycles in this variable definition
`TailCall` `processLeavingTail(XPathContext context)` Process the variable declaration
`void` `setContainsLocals(SlotManager map)` The expression that initializes a global variable may itself use local variables.
`void` `setExecutable(Executable executable)`
`void` `setHostLanguage(int language)`

Methods inherited from class net.sf.saxon.instruct.GeneralVariable

`display, evaluateItem, getCardinality, getInstructionNameCode, getItemType, getLocalSlotNumber, getNameCode, getRequiredType, getSelectExpression, getSlotNumber, getVariableFingerprint, getVariableName, init, isAssignable, isImplicitlyRequiredParam, isRequiredParam, isTunnelParam, iterate, iterateSubExpressions, optimize, replaceSubExpression, setAssignable, setImplicitlyRequiredParam, setNameCode, setReferenceCount, setRequiredParam, setRequiredType, setSelectExpression, setSlotNumber, setTunnel, setVariableName, simplify, typeCheck`

Methods inherited from class net.sf.saxon.instruct.Instruction
`appendItem, computeCardinality, computeSpecialProperties, createsNewNodes, evaluateAsString, getImplementationMethod, getSourceLocator, isXSLT, process, promote`

Methods inherited from class net.sf.saxon.expr.Expression

`adoptChildExpression, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, effectiveBooleanValue, getColumnNumber, getContainingProcedure, getDependencies, getIntrinsicDependencies, getLineNumber, getLocationId, getLocationProvider, getParentExpression, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasBadParentPointer, markTailFunctionCalls, resetStaticProperties, setLocationId, setParentExpression, setParentExpression, suppressValidation`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface javax.xml.transform.SourceLocator
`getColumnNumber, getLineNumber, getPublicId, getSystemId`

Constructor Detail

### GlobalVariable

    public GlobalVariable()

Method Detail

### getExecutable

    public Executable getExecutable()

  Description copied from class: `Expression`
  Get the executable containing this expression

  Specified by:
    `getExecutable` in interface `Container`
  Overrides:
    `getExecutable` in class `Expression`

### setExecutable

    public void setExecutable(Executable executable)

### setHostLanguage

    public void setHostLanguage(int language)

### getHostLanguage

    public int getHostLanguage()

  Description copied from class: `Expression`
  Get the host language (XSLT, XQuery, XPath) used to implement the code in this container

  Specified by:
    `getHostLanguage` in interface `Container`
  Overrides:
    `getHostLanguage` in class `Expression`
  Returns:
    typically `Configuration.XSLT` or `Configuration.XQUERY`

### setContainsLocals

    public void setContainsLocals(SlotManager map)

  The expression that initializes a global variable may itself use local variables. In this case a stack frame needs to be allocated while evaluating the global variable

  Parameters:
    `map` - The stack frame map for local variables used while evaluating this global variable.

### isGlobal

    public boolean isGlobal()

  Is this a global variable?

  Specified by:
    `isGlobal` in interface `Binding`
  Overrides:
    `isGlobal` in class `GeneralVariable`
  Returns:
    true (yes, it is a global variable)

### lookForCycles

    public void lookForCycles(Stack referees)
                       throws StaticError

  Check for cycles in this variable definition

  Parameters:
    `referees` - the calls leading up to this one; it's an error if this variable is on the stack, because that means it calls itself directly or indirectly. The stack may contain variable definitions (GlobalVariable objects) and user-defined functions (UserFunction objects). It will never contain the same object more than once.
  Throws:
    `StaticError`

### processLeavingTail

    public TailCall processLeavingTail(XPathContext context)
                                throws XPathException

  Process the variable declaration

  Specified by:
    `processLeavingTail` in interface `TailCallReturner`
  Specified by:
    `processLeavingTail` in class `Instruction`
  Parameters:
    `context` - The dynamic context of the transformation, giving access to the current node, the current variables, etc.
  Returns:
    null if the instruction has completed execution; or a TailCall indicating a function call or template call that is delegated to the caller, to be made after the stack has been unwound so as to save stack space.
  Throws:
    `XPathException`

### getSelectValue

    public ValueRepresentation getSelectValue(XPathContext context)
                                       throws XPathException

  Evaluate the variable. That is, get the value of the select expression if present or the content of the element otherwise, either as a tree or as a sequence

  Overrides:
    `getSelectValue` in class `GeneralVariable`
  Throws:
    `XPathException`

### evaluateVariable

    public ValueRepresentation evaluateVariable(XPathContext context)
                                         throws XPathException

  Evaluate the variable

  Throws:
    `XPathException`

### getInstructionInfo

    public InstructionInfo getInstructionInfo()

  Get InstructionInfo for this expression

  Specified by:
    `getInstructionInfo` in interface `InstructionInfoProvider`
  Overrides:
    `getInstructionInfo` in class `Instruction`

Copyright (C) Michael H. Kay. All rights reserved.