Package 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:
java.io.Serializable
,javax.xml.transform.SourceLocator
,LocationProvider
,SaxonLocator
,Binding
,Container
,EvaluableItem
,SequenceIterable
,TailCallReturner
,InstructionInfo
,org.xml.sax.Locator
- Direct Known Subclasses:
GlobalParam
public class GlobalVariable extends GeneralVariable implements Container
A compiled global variable in a stylesheet or query.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.instruct.GeneralVariable
evaluationMode, referenceCount, slotNumber, variableQName
-
Fields inherited from class net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, locationId, PROCESS_METHOD, staticProperties
-
-
Constructor Summary
Constructors Constructor Description GlobalVariable()
Create a global variable
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValueRepresentation
evaluateVariable(XPathContext context)
Evaluate the variableExecutable
getExecutable()
Get the executable containing this global variableint
getHostLanguage()
Get the host language for this declarationValueRepresentation
getSelectValue(XPathContext context)
Evaluate the variable.boolean
isGlobal()
Is this a global variable?void
lookForCycles(java.util.Stack referees, XQueryFunctionLibrary globalFunctionLibrary)
Check for cycles in this variable definitionTailCall
processLeavingTail(XPathContext context)
Process the variable declarationvoid
setContainsLocals(SlotManager map)
The expression that initializes a global variable may itself use local variables.void
setExecutable(Executable executable)
Set the containing executablevoid
setHostLanguage(int language)
Set the host language for this declaration-
Methods inherited from class net.sf.saxon.instruct.GeneralVariable
copy, evaluateItem, explain, getCardinality, getEvaluationMode, getInstructionNameCode, getItemType, getLocalSlotNumber, getRequiredType, getSelectExpression, getSlotNumber, getVariableQName, init, isAssignable, isImplicitlyRequiredParam, isRequiredParam, isTunnelParam, iterate, iterateSubExpressions, optimize, promoteInst, replaceSubExpression, setAssignable, setImplicitlyRequiredParam, setReferenceCount, setRequiredParam, setRequiredType, setSelectExpression, setSlotNumber, setTunnel, setVariableQName, simplify, typeCheck
-
Methods inherited from class net.sf.saxon.instruct.Instruction
assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, createsNewNodes, dynamicError, evaluateAsString, getConstructType, getImplementationMethod, getSourceLocator, isXSLT, process, promote
-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, display, doPromotion, dynamicError, effectiveBooleanValue, evaluatePendingUpdates, explain, findParentOf, getColumnNumber, getColumnNumber, getContainer, getDependencies, getIntrinsicDependencies, getLineNumber, getLineNumber, getLocationId, getLocationProvider, getObjectName, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, getSystemId, hasLoopingSubexpression, implementsStaticTypeCheck, isUpdatingExpression, iterateEvents, markTailFunctionCalls, resetLocalStaticProperties, setContainer, setFiltered, setFlattened, setLocationId, staticTypeCheck, suppressValidation, toString, typeError
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.expr.Container
getLocationProvider, replaceSubExpression
-
-
-
-
Method Detail
-
getExecutable
public Executable getExecutable()
Get the executable containing this global variable- Specified by:
getExecutable
in interfaceContainer
- Overrides:
getExecutable
in classExpression
- Returns:
- the containing executable
-
setExecutable
public void setExecutable(Executable executable)
Set the containing executable- Parameters:
executable
- the executable that contains this global variable
-
setHostLanguage
public void setHostLanguage(int language)
Set the host language for this declaration- Parameters:
language
- the host language (for example XSLT, XQuery)
-
getHostLanguage
public int getHostLanguage()
Get the host language for this declaration- Specified by:
getHostLanguage
in interfaceContainer
- Overrides:
getHostLanguage
in classExpression
- Returns:
- the host language (for example XSLT, 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 interfaceBinding
- Overrides:
isGlobal
in classGeneralVariable
- Returns:
- true (yes, it is a global variable)
-
lookForCycles
public void lookForCycles(java.util.Stack referees, XQueryFunctionLibrary globalFunctionLibrary) throws XPathException
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- Throws:
XPathException
-
processLeavingTail
public TailCall processLeavingTail(XPathContext context) throws XPathException
Process the variable declaration- Specified by:
processLeavingTail
in interfaceTailCallReturner
- Specified by:
processLeavingTail
in classInstruction
- 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 classGeneralVariable
- Parameters:
context
- the XPath dynamic context- Returns:
- the result of evaluating the variable
- Throws:
XPathException
-
evaluateVariable
public ValueRepresentation evaluateVariable(XPathContext context) throws XPathException
Evaluate the variable- Specified by:
evaluateVariable
in interfaceBinding
- Parameters:
context
- the XPath dynamic evaluation context- Returns:
- the result of evaluating the variable
- Throws:
XPathException
-
-