net.sf.saxon.instruct

Class CallTemplate

public class CallTemplate extends Instruction

Instruction representing an xsl:call-template element in the stylesheet.
Constructor Summary
CallTemplate(Template template, boolean useTailRecursion, Expression calledTemplateExpression, NamespaceResolver nsContext)
Construct a CallTemplate instruction.
Method Summary
booleancreatesNewNodes()
Determine whether this instruction creates new nodes.
voiddisplay(int level, NamePool pool, PrintStream out)
Diagnostic print of expression structure.
InstructionInfogetInstructionInfo()
Set additional trace properties appropriate to the kind of instruction.
intgetInstructionNameCode()
Return the name of this instruction.
intgetIntrinsicDependencies()
TemplategetTargetTemplate(XPathContext context)
Get the template, in the case where it is specified dynamically.
IteratoriterateSubExpressions()
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(Optimizer opt, StaticContext env, 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.
voidsetActualParameters(WithParam[] actualParams, WithParam[] tunnelParams)
Set the actual parameters on the call
Expressionsimplify(StaticContext env)
Simplify an expression.
ExpressiontypeCheck(StaticContext env, 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 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

createsNewNodes

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

display

public void display(int level, NamePool pool, PrintStream out)
Diagnostic print of expression structure. The expression is written to the System.err output stream

Parameters: level indentation level for this expression out

getInstructionInfo

public InstructionInfo getInstructionInfo()
Set additional trace properties appropriate to the kind of instruction. This implementation adds the template property, which identities the template to be called

getInstructionNameCode

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

getIntrinsicDependencies

public int getIntrinsicDependencies()

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 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(Optimizer opt, StaticContext env, 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

setActualParameters

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

simplify

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

Returns: the simplified expression

Throws: XPathException if an error is discovered during expression rewriting

typeCheck

public Expression typeCheck(StaticContext env, ItemType contextItemType)