com.icl.saxon

Class Bindery

public final class Bindery extends Object

The Bindery class holds information about variables and their values. Variables are identified by a Binding object. Values can be any object, though values of XSL variables will always be of class Value.
Method Summary
voidallocateGlobals(int n)
Define how many slots are needed for global variables
voidallocateLocals(int n)
Define how many slots are needed for local variables.
voidassignVariable(Binding binding, Value value)
Assign a new value to a variable
voidcloseStackFrame()
Close the current stack frame for local variables
voiddefineGlobalParameters(ParameterSet params)
Define global parameters
voiddefineGlobalVariable(Binding binding, Value value)
Define global variable
voiddefineLocalVariable(Binding binding, Value value)
Define local variable
intgetFrameId()
Get the id of the current frame.
ValuegetLocalParameter(int fingerprint)
Get local parameter.
ValuegetValue(Binding binding)
Get the value of a variable
ValuegetValue(Binding binding, int frameId)
Get the value of a variable in the given frame
booleanisEvaluated(Binding binding)
Test if global variable has already been evaluated
voidopenStackFrame(ParameterSet localParameters)
Start a new stack frame for local variables
voidsetExecuting(Binding binding, boolean executing)
Set/Unset a flag to indicate that a particular global variable is currently being evaluated.
booleanuseGlobalParameter(int fingerprint, Binding binding)
Use global parameter.
booleanuseLocalParameter(int fingerprint, Binding binding)
Use local parameter.

Method Detail

allocateGlobals

public void allocateGlobals(int n)
Define how many slots are needed for global variables

allocateLocals

public void allocateLocals(int n)
Define how many slots are needed for local variables. We work on the basis of "one size fits all": all stackframes are allocated as large as the largest one needed

assignVariable

public void assignVariable(Binding binding, Value value)
Assign a new value to a variable

Parameters: name the name of the local or global variable or parameter (without a $ sign)

Returns: the Value of the variable

Throws: SAXException if the variable has not been declared

closeStackFrame

public void closeStackFrame()
Close the current stack frame for local variables

defineGlobalParameters

public void defineGlobalParameters(ParameterSet params)
Define global parameters

Parameters: params The ParameterSet passed in by the user, eg. from the command line

defineGlobalVariable

public void defineGlobalVariable(Binding binding, Value value)
Define global variable

Parameters: name the name of the variable value the value of the variable

Throws: SAXException if the variable is already declared

defineLocalVariable

public void defineLocalVariable(Binding binding, Value value)
Define local variable

Parameters: name the name of the variable value the value of the variable

getFrameId

public int getFrameId()
Get the id of the current frame.

Returns: an id, that may be given to getValue(Binding,int)

getLocalParameter

public Value getLocalParameter(int fingerprint)
Get local parameter. This method is available to user-written node handlers invoked via the saxon:handler interface, it allows them to retrieve the values of parameters set up within a calling XSL template.

Returns: The value of the parameter, or null if not supplied

UNKNOWN: The name of the parameter (an absolute/expanded name, i.e. URI plus local part)

getValue

public Value getValue(Binding binding)
Get the value of a variable

Parameters: binding the Binding that establishes the unique instance of the variable

Returns: the Value of the variable if defined, null otherwise.

getValue

public Value getValue(Binding binding, int frameId)
Get the value of a variable in the given frame

Parameters: binding the Binding that establishes the unique instance of the variable frameId the id of the frame, see getFrameId

Returns: the Value of the variable if defined, null otherwise.

isEvaluated

public boolean isEvaluated(Binding binding)
Test if global variable has already been evaluated

openStackFrame

public void openStackFrame(ParameterSet localParameters)
Start a new stack frame for local variables

setExecuting

public void setExecuting(Binding binding, boolean executing)
Set/Unset a flag to indicate that a particular global variable is currently being evaluated.

Throws: XPathException If an attempt is made to set the flag when it is already set, this means the definition of the variable is circular.

useGlobalParameter

public boolean useGlobalParameter(int fingerprint, Binding binding)
Use global parameter. This is called when a global xsl:param element is processed. If a parameter of the relevant name was supplied, it is bound to the xsl:param element. Otherwise the method returns false, so the xsl:param default will be evaluated

Parameters: fingerprint The fingerprint of the parameter binding The XSLParam element to bind its value to

Returns: true if a parameter of this name was supplied, false if not

useLocalParameter

public boolean useLocalParameter(int fingerprint, Binding binding)
Use local parameter. This is called when a local xsl:param element is processed. If a parameter of the relevant name was supplied, it is bound to the xsl:param element. Otherwise the method returns false, so the xsl:param default will be evaluated

Parameters: fingerprint The fingerprint of the parameter name binding The XSLParam element to bind its value to

Returns: true if a parameter of this name was supplied, false if not