Class CallTemplate
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.instruct.Instruction
-
- net.sf.saxon.expr.instruct.CallTemplate
-
- All Implemented Interfaces:
ComponentInvocation,ContextOriginator,ExportAgent,ITemplateCall,TailCallReturner,Locatable,IdentityComparable,Traceable
public class CallTemplate extends Instruction implements ITemplateCall, ComponentInvocation
Instruction representing an xsl:call-template element in the stylesheet.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCallTemplate.CallTemplatePackageA CallTemplatePackage is an object that encapsulates the name of a template to be called, the parameters to be supplied, and the execution context.
-
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 Constructor Description CallTemplate(NamedTemplate template, StructuredQName calledTemplateName, boolean useTailRecursion, boolean inStreamable)Construct a CallTemplate instruction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcomputeCardinality()Get the cardinality of the sequence returned by evaluating this instructionExpressioncopy(RebindingMap rebindings)Copy an expression.voidexport(ExpressionPresenter out)Export of expression structure.WithParam[]getActualParams()Get the actual parameters passed to the called templateintgetBindingSlot()Get the binding slot to be used.StructuredQNamegetCalledTemplateName()Get the name (QName) of the template being calledComponentgetFixedTarget()Get the target component if this is known in advance, that is, if the target component is private or final, or in some other cases such as xsl:original.intgetInstructionNameCode()Return the name of this instruction.intgetIntrinsicDependencies()Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.ItemTypegetItemType()Get the item type of the items returned by evaluating this instructionStructuredQNamegetObjectName()Get a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc.java.lang.StringgetStreamerName()Get the (partial) name of a class that supports streaming of this kind of expressionSymbolicNamegetSymbolicName()Get the symbolic name of the template being called.ComponentgetTarget()NamedTemplategetTargetTemplate()Get the target templateWithParam[]getTunnelParams()Get the tunnel parameters passed to the called templatebooleanmayCreateNewNodes()Determine whether this instruction creates new nodes.java.lang.Iterable<Operand>operands()Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.Expressionoptimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType)Perform optimisation of an expression and its subexpressions.voidprocess(Outputter output, XPathContext context)Process this instruction, without leaving any tail calls.TailCallprocessLeavingTail(Outputter output, XPathContext context)Process this instruction.voidsetActualParameters(WithParam[] actualParams, WithParam[] tunnelParams)Set the actual parameters on the callvoidsetBindingSlot(int slot)Set the binding slot to be used.voidsetTargetTemplate(NamedTemplate target)Set the target templateExpressionsimplify()Simplify an expression.java.lang.StringtoShortString()Produce a short string identifying the expression for use in error messagesjava.lang.StringtoString()The toString() method for an expression attempts to give a representation of the expression in an XPath-like form.ExpressiontypeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)Perform type checking of an expression and its subexpressions.booleanusesTailRecursion()Ask whether this is a tail call-
Methods inherited from class net.sf.saxon.expr.instruct.Instruction
alwaysCreatesNewNodes, assembleParams, assembleTunnelParams, computeSpecialProperties, dynamicError, evaluateAsString, evaluateItem, getExpressionName, getImplementationMethod, getNetCost, getSourceLocator, isInstruction, isXSLT, iterate, someOperandCreatesNewNodes
-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeStaticProperties, dynamicError, effectiveBooleanValue, equals, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getLocalRetainedStaticContext, getLocation, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, typeCheckChildren, typeError, unordered, verifyParentPointers
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
-
-
-
Constructor Detail
-
CallTemplate
public CallTemplate(NamedTemplate template, StructuredQName calledTemplateName, boolean useTailRecursion, boolean inStreamable)
Construct a CallTemplate instruction.- Parameters:
template- the template to be called. This is provisional, and applies only if the template is not overridden in another package; the template supplied will be the one with matching name in the same package. Null in the case of saxon:call-template, and also in the case where the supplied name is xsl:originalcalledTemplateName- the name of the template to be called; null in the case of saxon:call-template where this is established dynamicallyuseTailRecursion- true if the call is potentially tail recursive where the name of the called template is to be calculated dynamically
-
-
Method Detail
-
setActualParameters
public void setActualParameters(WithParam[] actualParams, WithParam[] tunnelParams)
Set the actual parameters on the call- Parameters:
actualParams- the parameters that are not tunnel parameterstunnelParams- the tunnel parameters
-
getCalledTemplateName
public StructuredQName getCalledTemplateName()
Get the name (QName) of the template being called- Returns:
- the name of the target template
-
getSymbolicName
public SymbolicName getSymbolicName()
Get the symbolic name of the template being called. This is essentially the component kind (template) plus the QName of the target template- Specified by:
getSymbolicNamein interfaceComponentInvocation- Returns:
- the symbolic name of the target template, or null in the case of saxon:call-template where the name is defined dynamically
-
getTarget
public Component getTarget()
-
getFixedTarget
public Component getFixedTarget()
Description copied from interface:ComponentInvocationGet the target component if this is known in advance, that is, if the target component is private or final, or in some other cases such as xsl:original. Otherwise, return null.- Specified by:
getFixedTargetin interfaceComponentInvocation- Returns:
- the bound component if the binding has been fixed
-
getActualParams
public WithParam[] getActualParams()
Get the actual parameters passed to the called template- Specified by:
getActualParamsin interfaceITemplateCall- Returns:
- the non-tunnel parameters
-
getTunnelParams
public WithParam[] getTunnelParams()
Get the tunnel parameters passed to the called template- Specified by:
getTunnelParamsin interfaceITemplateCall- Returns:
- the tunnel parameters
-
setTargetTemplate
public void setTargetTemplate(NamedTemplate target)
Set the target template- Parameters:
target- the target template
-
getTargetTemplate
public NamedTemplate getTargetTemplate()
Get the target template- Returns:
- the target template
-
usesTailRecursion
public boolean usesTailRecursion()
Ask whether this is a tail call- Returns:
- true if this is a tail call
-
getInstructionNameCode
public int getInstructionNameCode()
Return the name of this instruction.- Overrides:
getInstructionNameCodein classInstruction- Returns:
- a code identifying the instruction: typically but not always the fingerprint of a name in the XSLT namespace
-
setBindingSlot
public void setBindingSlot(int slot)
Set the binding slot to be used. This is the offset within the binding vector of the containing component where the actual target template is to be found. The target template is not held directly in the CallTemplate instruction itself because it can be overridden in a using package.- Specified by:
setBindingSlotin interfaceComponentInvocation- Parameters:
slot- the offset in the binding vector of the containing package where the target template can be found.
-
getBindingSlot
public int getBindingSlot()
Get the binding slot to be used. This is the offset within the binding vector of the containing component where the actual target template is to be found.- Specified by:
getBindingSlotin interfaceComponentInvocation- Returns:
- the offset in the binding vector of the containing package where the target template can be found.
-
simplify
public Expression simplify() throws XPathException
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression).- Overrides:
simplifyin classExpression- Returns:
- the simplified expression
- Throws:
XPathException- if an error is discovered during expression rewriting
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) 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 visitorcontextInfo- 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)
-
optimize
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
Description copied from class:ExpressionPerform optimisation of an expression and its subexpressions. This is the third and final phase of static optimization.This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.
- Overrides:
optimizein classExpression- Parameters:
visitor- an expression visitorcontextItemType- the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set toType.ITEM_TYPE- Returns:
- the original expression, rewritten if appropriate to optimize execution
- Throws:
XPathException- if an error is discovered during this phase (typically a type error)
-
computeCardinality
public int computeCardinality()
Get the cardinality of the sequence returned by evaluating this instruction- Overrides:
computeCardinalityin classInstruction- Returns:
- the static cardinality
-
getItemType
public ItemType getItemType()
Get the item type of the items returned by evaluating this instruction- Overrides:
getItemTypein classInstruction- Returns:
- the static item type of the instruction
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.- Specified by:
copyin classExpression- Parameters:
rebindings- Variables that need to be re-bound- Returns:
- the copy of the original expression
-
getIntrinsicDependencies
public int getIntrinsicDependencies()
Description copied from class:ExpressionDetermine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. For example, position() has an intrinsic dependency on the context position, while (position()+1) does not. The default implementation of the method returns 0, indicating "no dependencies".- Overrides:
getIntrinsicDependenciesin classExpression- Returns:
- a set of bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
-
mayCreateNewNodes
public final boolean mayCreateNewNodes()
Determine whether this instruction creates new nodes. This implementation currently returns true unconditionally.- Overrides:
mayCreateNewNodesin classInstruction- Returns:
- true if the instruction creates new nodes under some input conditions (or if it can't be proved that it doesn't)
-
operands
public java.lang.Iterable<Operand> operands()
Description copied from class:ExpressionGet the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression. Default implementation works off the results of iterateSubExpressions()If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.
- Specified by:
operandsin classInstruction- Returns:
- an iterator containing the sub-expressions of this expression
-
process
public void process(Outputter output, XPathContext context) throws XPathException
Process this instruction, without leaving any tail calls.- Overrides:
processin classInstruction- Parameters:
output- the destination for the resultcontext- the dynamic context for this transformation- Throws:
XPathException- if a dynamic error occurs
-
processLeavingTail
public TailCall processLeavingTail(Outputter output, XPathContext context) throws XPathException
Process this instruction. If the called template contains a tail call (which may be an xsl:call-template or xsl:apply-templates instruction) then the tail call will not actually be evaluated, but will be returned in a TailCall object for the caller to execute.- Specified by:
processLeavingTailin interfaceTailCallReturner- Specified by:
processLeavingTailin classInstruction- Parameters:
output- the destination for the resultcontext- the dynamic context for this transformation- Returns:
- an object containing information about the tail call to be executed by the caller. Returns null if there is no tail call.
- Throws:
XPathException- if a dynamic error occurs during the evaluation of the instruction
-
getObjectName
public StructuredQName getObjectName()
Description copied from interface:TraceableGet a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc. This is used only where the name is known statically.- Specified by:
getObjectNamein interfaceTraceable- Overrides:
getObjectNamein classExpression- Returns:
- the QName of the object declared or manipulated by this instruction or expression
-
export
public void export(ExpressionPresenter out) throws XPathException
Export 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.
-
toString
public java.lang.String toString()
Description copied from class:ExpressionThe toString() method for an expression attempts to give a representation of the expression in an XPath-like form.
For subclasses of Expression that represent XPath expressions, the result should always be a string that parses as an XPath 3.0 expression. The expression produced should be equivalent to the original making certain assumptions about the static context. In general the expansion will make no assumptions about namespace bindings, except that (a) the prefix "xs" is used to refer to the XML Schema namespace, and (b) the default function namespace is assumed to be the "fn" namespace.
In the case of XSLT instructions and XQuery expressions, the toString() method gives an abstracted view of the syntax that is not designed in general to be parseable.
- Overrides:
toStringin classExpression- Returns:
- a representation of the expression as a string
-
toShortString
public java.lang.String toShortString()
Description copied from class:ExpressionProduce a short string identifying the expression for use in error messages- Overrides:
toShortStringin classExpression- Returns:
- a short string, sufficient to identify the expression
-
getStreamerName
public java.lang.String getStreamerName()
Description copied from class:ExpressionGet the (partial) name of a class that supports streaming of this kind of expression- Overrides:
getStreamerNamein classExpression- Returns:
- the partial name of a class that can be instantiated to provide streaming support in Saxon-EE, or null if there is no such class
-
-