net.sf.saxon.instruct

Class GlobalVariable

public class GlobalVariable extends GeneralVariable implements Container

A compiled global variable in a stylesheet or query.
Constructor Summary
GlobalVariable()
Create a global variable
Method Summary
ValueRepresentationevaluateVariable(XPathContext context)
Evaluate the variable
intgetContainerGranularity()
Get the granularity of the container.
ExecutablegetExecutable()
Get the executable containing this global variable
intgetHostLanguage()
Get the host language (XSLT, XQuery, XPath) used to implement the code in this container
ValueRepresentationgetSelectValue(XPathContext context)
Evaluate the variable.
booleanisGlobal()
Is this a global variable?
booleanisIndexedVariable()
Ask whether this is an indexed variable
voidlookForCycles(Stack referees, XQueryFunctionLibrary globalFunctionLibrary)
Check for cycles in this variable definition
TailCallprocessLeavingTail(XPathContext context)
Process the variable declaration
voidsetContainsLocals(SlotManager map)
The expression that initializes a global variable may itself use local variables.
voidsetExecutable(Executable executable)
Set the containing executable
voidsetIndexedVariable()
Mark this as an indexed variable, to allow fast searching

Constructor Detail

GlobalVariable

public GlobalVariable()
Create a global variable

Method Detail

evaluateVariable

public ValueRepresentation evaluateVariable(XPathContext context)
Evaluate the variable

getContainerGranularity

public int getContainerGranularity()
Get the granularity of the container.

Returns: 0 for a temporary container created during parsing; 1 for a container that operates at the level of an XPath expression; 2 for a container at the level of a global function or template

getExecutable

public Executable getExecutable()
Get the executable containing this global variable

Returns: the containing executable

getHostLanguage

public int getHostLanguage()
Get the host language (XSLT, XQuery, XPath) used to implement the code in this container

Returns: typically XSLT or XQUERY

getSelectValue

public ValueRepresentation getSelectValue(XPathContext context)
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

isGlobal

public boolean isGlobal()
Is this a global variable?

Returns: true (yes, it is a global variable)

isIndexedVariable

public boolean isIndexedVariable()
Ask whether this is an indexed variable

Returns: true if this variable is indexed

lookForCycles

public void lookForCycles(Stack referees, XQueryFunctionLibrary globalFunctionLibrary)
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. globalFunctionLibrary the library containing all global functions

processLeavingTail

public TailCall processLeavingTail(XPathContext context)
Process the variable declaration

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.

setExecutable

public void setExecutable(Executable executable)
Set the containing executable

Parameters: executable the executable that contains this global variable

setIndexedVariable

public void setIndexedVariable()
Mark this as an indexed variable, to allow fast searching