Class LocalParam
- All Implemented Interfaces:
Binding,ExportAgent,LocalBinding,Locatable,IdentityComparable,Traceable
The xsl:param element in XSLT has mandatory attribute name and optional attribute select. It can also be specified as required="yes" or required="no".
This is used only for parameters to XSLT templates. For function calls, the caller of the function
places supplied arguments onto the callee's stackframe and the callee does not need to do anything.
Global parameters (XQuery external variables) are handled using GlobalParam.
The LocalParam class is also used to represent parameters with the saxon:iterate instruction
Changed in Saxon 9.8 to combine the previously-separate LocalParamSetter and LocalParam classes into one
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe Elaborator for this kind of expression -
Field Summary
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddReference(VariableReference ref, boolean isLoopingReference) Register a variable reference that refers to the variable bound in this expressionvoidCheck the select expression against the required type.protected intGet the cardinality of the sequence returned by evaluating this instructionvoidprotected intGet the static properties of this expression (other than its type).copy(RebindingMap rebindings) Copy an expression.Evaluate the variablevoidDiagnostic print of expression structure.intGet the cardinality of the result of this instruction.Get the conversion expressionMake an elaborator for this expressionGet a name identifying the kind of expression, in terms meaningful to a user.intGet the name of this instruction for diagnostic and tracing purposesIf the variable is bound to an integer, get the minimum and maximum possible values.Get the item type of the items returned by evaluating this instructionintIf this is a local variable held on the local stack frame, return the corresponding slot number.Get the required type of this variableGet the expression to which this variable is boundintGet the slot number allocated to this variableGet the name of this variablebooleanhasVariableBinding(Binding binding) Ask whether this expression is, or contains, the binding of a given variablebooleanTest whether it is permitted to assign to the variable using the saxon:assign extension element.booleanisCompatible(LocalParam other) Check if parameter is compatible with anotherbooleanisGlobal()Indicate whether the binding is local or global.booleanAsk whether this variable represents a parameter that is implicitly required, because there is no usable default valuebooleanAsk whether the binding is to be indexedbooleanisLiftable(boolean forStreaming) Ask whether the expression can be lifted out of a loop, assuming it has no dependencies on the controlling variable/focus of the loopbooleanAsk whether this variable represents a required parameterbooleanAsk whether this variable represents a tunnel parameterbooleanDetermine whether this instruction creates new nodes.operands()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)voidsetConversion(Expression convertor) Define a conversion that is to be applied to the supplied parameter value.voidsetImplicitlyRequiredParam(boolean requiredParam) Indicate that this variable represents a parameter that is implicitly required (because there is no usable default value)voidSay that the bound value has the potential to be indexedvoidsetReferenceCount(int refCount) Set the nominal number of references to this variablevoidsetRequiredParam(boolean requiredParam) Indicate that this variable represents a required parametervoidsetRequiredType(SequenceType required) Set the required type of this variablevoidsetSelectExpression(Expression select) Set the expression to which this variable is boundvoidsetSlotNumber(int s) Set the slot number of this variablevoidsetTunnel(boolean tunnel) Indicate whether this variable represents a tunnel parametervoidSet the name of the variableProduce a short string identifying the expression for use in error messagestypeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) Perform type checking of an expression and its subexpressions.Methods inherited from class net.sf.saxon.expr.instruct.Instruction
alwaysCreatesNewNodes, assembleParams, assembleTunnelParams, dynamicError, evaluateAsString, evaluateItem, getImplementationMethod, getNetCost, getSourceLocator, isInstruction, isXSLT, iterate, process, someOperandCreatesNewNodesMethods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeStaticProperties, dispatchTailCall, dynamicError, effectiveBooleanValue, equals, explain, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, makeElaborator, markTailFunctionCalls, operandList, operandSparseList, optimize, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, toPattern, toString, typeCheckChildren, typeError, unordered, verifyParentPointers, withLocationMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
Constructor Details
-
LocalParam
public LocalParam()
-
-
Method Details
-
setSelectExpression
Set the expression to which this variable is bound- Parameters:
select- the initializing expression
-
getSelectExpression
Get the expression to which this variable is bound- Returns:
- the initializing expression
-
setRequiredType
Set the required type of this variable- Parameters:
required- the required type
-
getRequiredType
Get the required type of this variable- Specified by:
getRequiredTypein interfaceBinding- Returns:
- the required type
-
setRequiredParam
public void setRequiredParam(boolean requiredParam) Indicate that this variable represents a required parameter- Parameters:
requiredParam- true if this is a required parameter
-
setImplicitlyRequiredParam
public void setImplicitlyRequiredParam(boolean requiredParam) Indicate that this variable represents a parameter that is implicitly required (because there is no usable default value)- Parameters:
requiredParam- true if this is an implicitly required parameter
-
setTunnel
public void setTunnel(boolean tunnel) Indicate whether this variable represents a tunnel parameter- Parameters:
tunnel- true if this is a tunnel parameter
-
setReferenceCount
public void setReferenceCount(int refCount) Set the nominal number of references to this variable- Parameters:
refCount- the nominal number of references
-
getCardinality
public int getCardinality()Get the cardinality of the result of this instruction. An xsl:variable instruction returns nothing, so the type is empty.- Overrides:
getCardinalityin classExpression- Returns:
- the empty cardinality.
-
isAssignable
public boolean isAssignable()Description copied from interface:BindingTest whether it is permitted to assign to the variable using the saxon:assign extension element. This will only be for an XSLT global variable where the extra attribute saxon:assignable="yes" is present.- Specified by:
isAssignablein interfaceBinding- Returns:
- true if the binding is assignable
-
isGlobal
public boolean isGlobal()Description copied from interface:BindingIndicate whether the binding is local or global. A global binding is one that has a fixed value for the life of a query or transformation; any other binding is local. -
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.- Specified by:
getLocalSlotNumberin interfaceLocalBinding- Returns:
- the slot number on the local stack frame
-
isRequiredParam
public boolean isRequiredParam()Ask whether this variable represents a required parameter- Returns:
- true if this is a required parameter
-
isImplicitlyRequiredParam
public boolean isImplicitlyRequiredParam()Ask whether this variable represents a parameter that is implicitly required, because there is no usable default value- Returns:
- true if this variable is an implicitly required parameter
-
isTunnelParam
public boolean isTunnelParam()Ask whether this variable represents a tunnel parameter- Returns:
- true if this is a tunnel parameter
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException Description copied from class:ExpressionPerform type checking of an expression and its subexpressions. This is the second phase of static optimization.This checks statically that the operands of the expression have the correct type; if necessary it generates code to do run-time type checking or type conversion. A static type error is reported only if execution cannot possibly succeed, that is, if a run-time type error is inevitable. The call may return a modified form of the expression.
This method is called after all references to functions and variables have been resolved to the declaration of the function or variable. However, the types of such functions and variables may not be accurately known if they have not been explicitly declared.
- Overrides:
typeCheckin classExpression- Parameters:
visitor- an expression visitorcontextItemType- Information available statically about the context item: whether it is (possibly) absent; its static type; its streaming posture.- Returns:
- the original expression, rewritten to perform necessary run-time type checks, and to perform other type-related optimizations
- Throws:
XPathException- if an error is discovered during this phase (typically a type error)
-
computeEvaluationMode
public void computeEvaluationMode() -
copy
Copy an expression. This makes a deep copy.- Specified by:
copyin classExpression- Parameters:
rebindings- a mutable list of (old binding, new binding) pairs that is used to update the bindings held in any local variable references that are copied.- Returns:
- the copy of the original expression
-
addReference
Description copied from interface:BindingRegister a variable reference that refers to the variable bound in this expression- Specified by:
addReferencein interfaceBinding- Parameters:
ref- the variable referenceisLoopingReference- - true if the reference occurs within a loop, such as the predicate of a filter expression
-
checkAgainstRequiredType
Check the select expression against the required type.- Parameters:
visitor- an expression visitor- Throws:
XPathException- if the check fails
-
getSlotNumber
public int getSlotNumber()Get the slot number allocated to this variable- Returns:
- the slot number, that is the position allocated to the variable on its stack frame
-
setSlotNumber
public void setSlotNumber(int s) Set the slot number of this variable- Parameters:
s- the slot number, that is, the position allocated to this variable on its stack frame
-
setVariableQName
Set the name of the variable- Parameters:
s- the name of the variable (a QName)
-
getVariableQName
Get the name of this variable- Specified by:
getVariableQNamein interfaceBinding- Returns:
- the name of this variable (a QName)
-
setConversion
Define a conversion that is to be applied to the supplied parameter value.- Parameters:
convertor- The expression to be applied. This performs type checking, and the basic conversions implied by function calling rules, for example numeric promotion, atomization, and conversion of untyped atomic values to a required type. The conversion uses the actual parameter value as input, referencing it using a VariableReference. The argument can be null to indicate that no conversion is required.
-
getConversion
Get the conversion expression- Returns:
- the expression used to convert the value to the required type, or null if there is none
-
getInstructionNameCode
public int getInstructionNameCode()Get the name of this instruction for diagnostic and tracing purposes- Overrides:
getInstructionNameCodein classInstruction- Returns:
- the integer name code
-
operands
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)- Specified by:
operandsin classInstruction- Returns:
- an iterator over the subexpressions
-
getIntegerBoundsForVariable
If the variable is bound to an integer, get the minimum and maximum possible values. Return null if unknown or not applicable- Specified by:
getIntegerBoundsForVariablein interfaceBinding- Returns:
- a pair of integers containing the minimum and maximum values for the integer value; or null if the value is not an integer or the range is unknown
-
evaluateVariable
Evaluate the variable- Specified by:
evaluateVariablein interfaceBinding- Parameters:
c- the XPath dynamic evaluation context- Returns:
- the result of evaluating the variable
-
isCompatible
Check if parameter is compatible with another- Parameters:
other- - the LocalParam object to compare- Returns:
- result of the compatibility check
-
isLiftable
public boolean isLiftable(boolean forStreaming) Ask whether the expression can be lifted out of a loop, assuming it has no dependencies on the controlling variable/focus of the loop- Overrides:
isLiftablein classExpression- Parameters:
forStreaming- true if compiling streamable code- Returns:
- true if the expression can be loop lifted
-
hasVariableBinding
Ask whether this expression is, or contains, the binding of a given variable- Overrides:
hasVariableBindingin classExpression- Parameters:
binding- the variable binding- Returns:
- true if this expression is the variable binding (for example a ForExpression or LetExpression) or if it is a FLWOR expression that binds the variable in one of its clauses.
-
getItemType
Get the item type of the items returned by evaluating this instruction- Overrides:
getItemTypein classInstruction- Returns:
- the static item type of the instruction
-
computeCardinality
protected int computeCardinality()Get the cardinality of the sequence returned by evaluating this instruction- Overrides:
computeCardinalityin classInstruction- Returns:
- the static cardinality
-
computeSpecialProperties
protected int computeSpecialProperties()Get the static properties of this expression (other than its type). The result is bit-signficant. These properties are used for optimizations. In general, if property bit is set, it is true, but if it is unset, the value is unknown.- Overrides:
computeSpecialPropertiesin classInstruction- Returns:
- a set of flags indicating static properties of this expression
-
mayCreateNewNodes
public boolean mayCreateNewNodes()Determine whether this instruction creates new nodes. This implementation returns a default value of false- Overrides:
mayCreateNewNodesin classInstruction- Returns:
- true if the instruction creates new nodes (or if it can't be proved that it doesn't)
-
getExpressionName
Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionNamein classInstruction- Returns:
- a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in explain() output displaying the expression.
-
toShortString
Produce a short string identifying the expression for use in error messages- Overrides:
toShortStringin classExpression- Returns:
- a short string, sufficient to identify the expression
-
export
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
exportin interfaceExportAgent- Specified by:
exportin classExpression- Parameters:
out- the expression presenter used to display the structure- Throws:
XPathException- if the export fails, for example if an expression is found that won't work in the target environment.
-
setIndexedVariable
public void setIndexedVariable()Say that the bound value has the potential to be indexed- Specified by:
setIndexedVariablein interfaceLocalBinding
-
isIndexedVariable
public boolean isIndexedVariable()Ask whether the binding is to be indexed- Specified by:
isIndexedVariablein interfaceLocalBinding- Returns:
- true if the variable value can be indexed
-
getElaborator
Make an elaborator for this expression- Overrides:
getElaboratorin classExpression- Returns:
- an appropriate
Elaborator
-