net.sf.saxon.instruct

Class CallTemplate

public class CallTemplate extends Instruction

Instruction representing an xsl:call-template element in the stylesheet.
Nested Class Summary
static classCallTemplate.CallTemplatePackage
A CallTemplatePackage is an object that encapsulates the name of a template to be called, the parameters to be supplied, and the execution context.
Constructor Summary
CallTemplate(Template template, boolean useTailRecursion, Expression calledTemplateExpression, NamespaceResolver nsContext)
Construct a CallTemplate instruction.
Method Summary
intcomputeCardinality()
Get the cardinality of the sequence returned by evaluating this instruction
Expressioncopy()
Copy an expression.
booleancreatesNewNodes()
Determine whether this instruction creates new nodes.
voidexplain(ExpressionPresenter out)
Diagnostic print of expression structure.
intgetInstructionNameCode()
Return the name of this instruction.
intgetIntrinsicDependencies()
ItemTypegetItemType(TypeHierarchy th)
Get the item type of the items returned by evaluating this instruction
StructuredQNamegetObjectName()
TemplategetTargetTemplate(XPathContext context)
Get the template, in the case where it is specified dynamically.
Iterator<Expression>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)
Expressionoptimize(ExpressionVisitor visitor, ItemType contextItemType)
voidprocess(XPathContext context)
Process this instruction, without leaving any tail calls.
TailCallprocessLeavingTail(XPathContext context)
Process this instruction.
protected voidpromoteInst(PromotionOffer offer)
Handle promotion offers, that is, non-local tree rewrites.
booleanreplaceSubExpression(Expression original, Expression replacement)
Replace one subexpression by a replacement subexpression
voidsetActualParameters(WithParam[] actualParams, WithParam[] tunnelParams)
Set the actual parameters on the call
Expressionsimplify(ExpressionVisitor visitor)
Simplify an expression.
ExpressiontypeCheck(ExpressionVisitor visitor, ItemType contextItemType)

Constructor Detail

CallTemplate

public CallTemplate(Template template, boolean useTailRecursion, Expression calledTemplateExpression, NamespaceResolver nsContext)
Construct a CallTemplate instruction.

Parameters: template the Template object identifying the template to be called, in the normal case where this is known statically useTailRecursion true if the call is potentially tail recursive calledTemplateExpression expression to calculate the name of the template to be called at run-time, this supports the saxon:allow-avt option nsContext the static namespace context of the instruction, needed only in the case where the name of the called template is to be calculated dynamically

Method Detail

computeCardinality

public int computeCardinality()
Get the cardinality of the sequence returned by evaluating this instruction

Returns: the static cardinality

copy

public Expression copy()
Copy an expression. This makes a deep copy.

Returns: the copy of the original expression

createsNewNodes

public final boolean createsNewNodes()
Determine whether this instruction creates new nodes. This implementation currently returns true unconditionally.

explain

public void explain(ExpressionPresenter out)
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.

getInstructionNameCode

public int getInstructionNameCode()
Return the name of this instruction.

getIntrinsicDependencies

public int getIntrinsicDependencies()

getItemType

public ItemType getItemType(TypeHierarchy th)
Get the item type of the items returned by evaluating this instruction

Parameters: th the type hierarchy cache

Returns: the static item type of the instruction

getObjectName

public StructuredQName getObjectName()

getTargetTemplate

public Template getTargetTemplate(XPathContext context)
Get the template, in the case where it is specified dynamically.

Parameters: context The dynamic context of the transformation

Returns: The template to be called

Throws: XPathException if a dynamic error occurs: specifically, if the template name is computed at run-time (Saxon extension) and the name is invalid or does not reference a known template

iterateSubExpressions

public Iterator<Expression> 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)

optimize

public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType)

process

public void process(XPathContext context)
Process this instruction, without leaving any tail calls.

Parameters: context the dynamic context for this transformation

Throws: XPathException if a dynamic error occurs

processLeavingTail

public TailCall processLeavingTail(XPathContext context)
Process this instruction. If the called template contains a tail call (which may be an xsl:call-template of 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.

Parameters: context 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.

promoteInst

protected void promoteInst(PromotionOffer offer)
Handle promotion offers, that is, non-local tree rewrites.

Parameters: offer The type of rewrite being offered

Throws: net.sf.saxon.trans.XPathException

replaceSubExpression

public boolean replaceSubExpression(Expression original, Expression replacement)
Replace one subexpression by a replacement subexpression

Parameters: original the original subexpression replacement the replacement subexpression

Returns: true if the original subexpression is found

setActualParameters

public void setActualParameters(WithParam[] actualParams, WithParam[] tunnelParams)
Set the actual parameters on the call

Parameters: actualParams the parameters that are not tunnel parameters tunnelParams the tunnel parameters

simplify

public Expression simplify(ExpressionVisitor visitor)
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression).

Parameters: visitor an expression visitor

Returns: the simplified expression

Throws: XPathException if an error is discovered during expression rewriting

typeCheck

public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType)