net.sf.saxon.instruct

Class ApplyTemplates

public class ApplyTemplates extends Instruction

An instruction representing an xsl:apply-templates element in the stylesheet
Constructor Summary
ApplyTemplates(Expression select, boolean useCurrentMode, boolean useTailRecursion, Mode mode, boolean backwardsCompatible)
Method Summary
static TailCallapplyTemplates(SequenceIterator iterator, Mode mode, ParameterSet parameters, ParameterSet tunnelParameters, XPathContextMajor context, boolean backwardsCompatible, int locationId)
Process selected nodes using the handlers registered for a particular mode.
booleancreatesNewNodes()
Determine whether this instruction creates new nodes.
static voiddefaultAction(NodeInfo node, ParameterSet parameters, ParameterSet tunnelParams, XPathContext context, boolean backwardsCompatible, int locationId)
Perform the built-in template action for a given node.
voiddisplay(int level, NamePool pool, PrintStream out)
Diagnostic print of expression structure.
InstructionInfogetInstructionInfo()
Set additional trace properties appropriate to the kind of instruction.
intgetInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes
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)
TailCallprocessLeavingTail(XPathContext context)
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

ApplyTemplates

public ApplyTemplates(Expression select, boolean useCurrentMode, boolean useTailRecursion, Mode mode, boolean backwardsCompatible)

Method Detail

applyTemplates

public static TailCall applyTemplates(SequenceIterator iterator, Mode mode, ParameterSet parameters, ParameterSet tunnelParameters, XPathContextMajor context, boolean backwardsCompatible, int locationId)
Process selected nodes using the handlers registered for a particular mode.

Parameters: iterator an Iterator over the nodes to be processed, in the correct (sorted) order mode Identifies the processing mode. It should match the mode defined when the element handler was registered using setHandler with a mode parameter. Set this parameter to null to invoke the default mode. parameters A ParameterSet containing the parameters to the handler/template being invoked. Specify null if there are no parameters. tunnelParameters A ParameterSet containing the parameters to the handler/template being invoked. Specify null if there are no parameters. context A newly-created context object locationId

Returns: a TailCall returned by the last template to be invoked, or null, indicating that there are no outstanding tail calls.

Throws: XPathException if any dynamic error occurs

createsNewNodes

public final boolean createsNewNodes()
Determine whether this instruction creates new nodes. This implementation returns true (which is almost invariably the case, so it's not worth doing any further analysis to find out more precisely).

defaultAction

public static void defaultAction(NodeInfo node, ParameterSet parameters, ParameterSet tunnelParams, XPathContext context, boolean backwardsCompatible, int locationId)
Perform the built-in template action for a given node.

Parameters: node the node to be processed parameters the parameters supplied to apply-templates tunnelParams the tunnel parameters to be passed through backwardsCompatible true if in 1.0 mode (currently makes no difference) locationId location of the instruction (apply-templates, apply-imports etc) that caused the built-in template to be invoked

Throws: XPathException if any dynamic error occurs

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 mode attribute

getInstructionNameCode

public int getInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes

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)

processLeavingTail

public TailCall processLeavingTail(XPathContext context)

promoteInst

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

Parameters: offer The type of rewrite being offered

Throws: 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)