This class defines common behaviour across xsl:variable, xsl:param, and xsl:with-param;
also saxon:assign
copy
public Expression copy()
Copy an expression. This makes a deep copy.
- copy in interface Expression
- the copy of the original expression
evaluateItem
public Item evaluateItem(XPathContext context)
throws XPathException
Evaluate an expression as a single item. This always returns either a single Item or
null (denoting the empty sequence). No conversion is done. This method should not be
used unless the static type of the expression is a subtype of "item" or "item?": that is,
it should not be called if the expression may return a sequence. There is no guarantee that
this condition will be detected.
- evaluateItem in interface EvaluableItem
- evaluateItem in interface Instruction
context
- The context in which the expression is to be evaluated
- the node or atomic value that results from evaluating the
expression; or null to indicate that the result is an empty
sequence
XPathException
- if any dynamic error occurs evaluating the
expression
explain
public void explain(ExpressionPresenter out)
Diagnostic print of expression structure. The abstract expression tree
is written to the supplied output destination.
- explain in interface Expression
getCardinality
public int getCardinality()
Get the cardinality of the result of this instruction. An xsl:variable instruction returns nothing, so the
type is empty.
- getCardinality in interface Expression
getEvaluationMode
public int getEvaluationMode()
Get the evaluation mode of the variable
getInstructionNameCode
public int getInstructionNameCode()
Get the name of this instruction (that is xsl:variable, xsl:param etc) for diagnostics
- getInstructionNameCode in interface Instruction
- the name of this instruction, as a name pool name code
getItemType
public ItemType getItemType(TypeHierarchy th)
Get the type of the result of this instruction. An xsl:variable instruction returns nothing, so the
type is empty.
- getItemType in interface Instruction
th
- the type hierarchy cache
getLocalSlotNumber
public int getLocalSlotNumber()
If this is a local variable held on the local stack frame, return the corresponding slot number.
In other cases, return -1.
- getLocalSlotNumber in interface Binding
getSelectExpression
public Expression getSelectExpression()
Get the expression to which this variable is bound
- the initializing expression
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
context
- the XPath dynamic context
- the result of evaluating the variable
getSlotNumber
public int getSlotNumber()
Get the slot number allocated to this variable
- the slot number, that is the position allocated to the variable on its stack frame
init
public void init(Expression select,
StructuredQName qName)
Initialize the properties of the variable
select
- the expression to which the variable is boundqName
- the name of the variable
isAssignable
public final boolean isAssignable()
Test whether it is permitted to assign to the variable using the saxon:assign
extension element. This will only be true if the extra attribute saxon:assignable="yes"
is present.
- isAssignable in interface Binding
isImplicitlyRequiredParam
public final boolean isImplicitlyRequiredParam()
Ask whether this variable represents a parameter that is implicitly required, because there is no usable
default value
- true if this variable is an implicitly required parameter
isRequiredParam
public final boolean isRequiredParam()
Ask whether this variable represents a required parameter
- true if this is a required parameter
isTunnelParam
public final boolean isTunnelParam()
Ask whether this variable represents a tunnel parameter
- true if this is a tunnel parameter
iterate
public SequenceIterator iterate(XPathContext context)
throws XPathException
Return an Iterator to iterate over the values of a sequence. The value of every
expression can be regarded as a sequence, so this method is supported for all
expressions. This default implementation relies on the process() method: it
"pushes" the results of the instruction to a sequence in memory, and then
iterates over this in-memory sequence.
In principle instructions should implement a pipelined iterate() method that
avoids the overhead of intermediate storage.
- iterate in interface SequenceIterable
- iterate in interface Instruction
context
- supplies the context for evaluation
- a SequenceIterator that can be used to iterate over the result
of the expression
XPathException
- if any dynamic error occurs evaluating the
expression
iterateSubExpressions
public Iterator iterateSubExpressions()
Get all the XPath expressions associated with this instruction
(in XSLT terms, the expression present on attributes of the instruction,
as distinct from the child instructions in a sequence construction)
- iterateSubExpressions in interface Expression
replaceSubExpression
public boolean replaceSubExpression(Expression original,
Expression replacement)
Replace one subexpression by a replacement subexpression
- replaceSubExpression in interface Expression
original
- the original subexpressionreplacement
- the replacement subexpression
- true if the original subexpression is found
setAssignable
public void setAssignable(boolean assignable)
Indicate whether this variable is assignable using saxon:assign
assignable
- true if this variable is assignable
setImplicitlyRequiredParam
public void setImplicitlyRequiredParam(boolean requiredParam)
Indicate that this variable represents a parameter that is implicitly required (because there is no
usable default value)
requiredParam
- true if this is an implicitly required parameter
setReferenceCount
public void setReferenceCount(int refCount)
Set the nominal number of references to this variable
refCount
- the nominal number of references
setRequiredParam
public void setRequiredParam(boolean requiredParam)
Indicate that this variable represents a required parameter
requiredParam
- true if this is a required parameter
setRequiredType
public void setRequiredType(SequenceType required)
Set the required type of this variable
required
- the required type
setSelectExpression
public void setSelectExpression(Expression select)
Set the expression to which this variable is bound
select
- the initializing expression
setSlotNumber
public void setSlotNumber(int s)
Set the slot number of this variable
s
- the slot number, that is, the position allocated to this variable on its stack frame
setTunnel
public void setTunnel(boolean tunnel)
Indicate whether this variable represents a tunnel parameter
tunnel
- true if this is a tunnel parameter
setVariableQName
public void setVariableQName(StructuredQName s)
Set the name of the variable
s
- the name of the variable (a QName)