Class ApplyTemplates
- All Implemented Interfaces:
ComponentInvocation
,ContextOriginator
,ExportAgent
,ITemplateCall
,Locatable
,IdentityComparable
,Traceable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
protected static class
An ApplyTemplatesPackage is an object that encapsulates the sequence of nodes to be processed, the mode, the parameters to be supplied, and the execution context. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected boolean
protected boolean
protected Mode
protected RuleManager
protected boolean
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
ConstructorsModifierConstructorDescriptionprotected
ApplyTemplates
(Expression select, boolean useCurrentMode, boolean useTailRecursion, boolean implicitSelect, boolean inStreamableConstruct, Mode mode, RuleManager ruleManager) Construct an apply-templates instruction -
Method Summary
Modifier and TypeMethodDescriptionaddToPathMap
(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet) Add a representation of this expression to a PathMap.copy
(RebindingMap rebindings) Copy an expression.void
Diagnostic print of expression structure.Get the actual parameters passed to the called templateint
Get the binding slot to be used (for the explicit or implicit reference to the mode).Make an elaborator for this expressionGet 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.int
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().int
Get the name of this instruction for diagnostic and tracing purposesint
Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.getMode()
Get the ModeGet the select expressionGet the select expressionGet the (partial) name of a class that supports streaming of this kind of expressionGet the symbolic name of the mode that this invocation referencesgetTargetMode
(XPathContext context) Establish the target mode, at run-time.Get the tunnel parameters passed to the called templateprotected void
init
(Expression select, boolean useCurrentMode, boolean useTailRecursion, Mode mode) boolean
Ask if the select expression was implicitfinal boolean
Determine whether this instruction creates new nodes.operands()
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.optimize
(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) Perform optimisation of an expression and its subexpressions.void
setActualParams
(WithParam[] params) void
setBindingSlot
(int slot) Set the binding slot to be used (for the explicit or implicit reference to the mode).void
setMode
(SimpleMode target) Set the mode to be used.void
setSelect
(Expression select) Set the select expressionvoid
setSeparatorExpression
(Expression separator) Set the separator expression (Saxon extension)void
setTunnelParams
(WithParam[] params) simplify()
Simplify an expression.typeCheck
(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) Perform type checking of an expression and its subexpressions.boolean
Ask if mode="#current" was specifiedboolean
Ask if tail recursion is to be usedMethods inherited from class net.sf.saxon.expr.instruct.Instruction
alwaysCreatesNewNodes, assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, dynamicError, evaluateAsString, evaluateItem, getExpressionName, getItemType, getNetCost, getSourceLocator, isInstruction, isXSLT, iterate, process, someOperandCreatesNewNodes
Methods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeStaticProperties, dispatchTailCall, dynamicError, effectiveBooleanValue, equals, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getLocalRetainedStaticContext, getLocation, getObjectName, 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, makeElaborator, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, toPattern, toShortString, toString, typeCheckChildren, typeError, unordered, verifyParentPointers, withLocation
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
-
Field Details
-
useCurrentMode
protected boolean useCurrentMode -
_useTailRecursion
protected boolean _useTailRecursion -
mode
-
implicitSelect
protected boolean implicitSelect -
inStreamableConstruct
protected boolean inStreamableConstruct -
ruleManager
-
-
Constructor Details
-
ApplyTemplates
protected ApplyTemplates() -
ApplyTemplates
public ApplyTemplates(Expression select, boolean useCurrentMode, boolean useTailRecursion, boolean implicitSelect, boolean inStreamableConstruct, Mode mode, RuleManager ruleManager) Construct an apply-templates instruction- Parameters:
select
- the select expressionuseCurrentMode
- true if mode="#current" was specifieduseTailRecursion
- true if this instruction is the last in its templateimplicitSelect
- true if the select expression is implicit, that is, if there was no explicit select expression in the call. This information is used only to make error messages more meaningful.inStreamableConstruct
- true if the apply-templates instruction appears within a streamable construct such as a streamable template rulemode
- the mode specified on apply-templatesruleManager
- the rule manager
-
-
Method Details
-
init
-
setMode
Set the mode to be used.- Parameters:
target
- the attribute set to be used
-
setSeparatorExpression
Set the separator expression (Saxon extension)- Parameters:
separator
- the separator expression
-
getSeparatorExpression
-
getActualParams
Get the actual parameters passed to the called template- Specified by:
getActualParams
in interfaceITemplateCall
- Returns:
- the non-tunnel parameters
-
getTunnelParams
Get the tunnel parameters passed to the called template- Specified by:
getTunnelParams
in interfaceITemplateCall
- Returns:
- the tunnel parameters
-
setActualParams
-
setTunnelParams
-
operands
Description copied from class:Expression
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.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:
operands
in classInstruction
- Returns:
- an iterator containing the sub-expressions of this expression
-
getInstructionNameCode
public int getInstructionNameCode()Get the name of this instruction for diagnostic and tracing purposes- Overrides:
getInstructionNameCode
in classInstruction
- Returns:
- a code identifying the instruction: typically but not always the fingerprint of a name in the XSLT namespace
-
getImplementationMethod
public int getImplementationMethod()An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is prefered. For instructions this is the process() method.- Overrides:
getImplementationMethod
in classInstruction
- Returns:
- the implementation method, for example
Expression.ITERATE_METHOD
orExpression.EVALUATE_METHOD
orExpression.PROCESS_METHOD
-
simplify
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression).- Overrides:
simplify
in classExpression
- Returns:
- the simplified expression (or the original if unchanged, or if modified in-situ)
- Throws:
XPathException
- if an error is discovered during expression rewriting
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException Description copied from class:Expression
Perform 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:
typeCheck
in 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 contextInfo) throws XPathException Description copied from class:Expression
Perform 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:
optimize
in classExpression
- Parameters:
visitor
- an expression visitorcontextInfo
- 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)
-
getIntrinsicDependencies
public int getIntrinsicDependencies()Description copied from class:Expression
Determine 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:
getIntrinsicDependencies
in classExpression
- Returns:
- an integer containing bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
-
getRuleManager
-
copy
Copy an expression. This makes a deep copy.- Specified by:
copy
in 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
-
mayCreateNewNodes
public final boolean mayCreateNewNodes()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).- Overrides:
mayCreateNewNodes
in classInstruction
- Returns:
- true if the instruction creates new nodes under some input conditions (or if it can't be proved that it doesn't)
-
getTargetMode
Establish the target mode, at run-time. This (a) resolves overrides across packages, and (b) handles mode="#current".- Parameters:
context
- the dynamic context- Returns:
- the mode to be used, as a Component
-
getSelectExpression
Get the select expression- Returns:
- the select expression
-
isImplicitSelect
public boolean isImplicitSelect()Ask if the select expression was implicit- Returns:
- true if no select attribute was explicitly specified
-
useTailRecursion
public boolean useTailRecursion()Ask if tail recursion is to be used- Returns:
- true if tail recursion is used
-
usesCurrentMode
public boolean usesCurrentMode()Ask if mode="#current" was specified- Returns:
- true if mode="#current" was specified
-
getMode
Get the Mode- Returns:
- the mode, or null if mode="#current" was specified
-
getFixedTarget
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. Otherwise, return null.- Specified by:
getFixedTarget
in interfaceComponentInvocation
- Returns:
- the bound component if the binding has been fixed
-
getSymbolicName
Get the symbolic name of the mode that this invocation references- Specified by:
getSymbolicName
in interfaceComponentInvocation
- Returns:
- the symbolic name of the mode used by this instructon, or null if the instruction uses mode="#current"
-
addToPathMap
Add a representation of this expression to a PathMap. The PathMap captures a map of the nodes visited by an expression in a source tree.The default implementation of this method assumes that an expression does no navigation other than the navigation done by evaluating its subexpressions, and that the subexpressions are evaluated in the same context as the containing expression. The method must be overridden for any expression where these assumptions do not hold. For example, implementations exist for AxisExpression, ParentExpression, and RootExpression (because they perform navigation), and for the doc(), document(), and collection() functions because they create a new navigation root. Implementations also exist for PathExpression and FilterExpression because they have subexpressions that are evaluated in a different context from the calling expression.
- Overrides:
addToPathMap
in classExpression
- Parameters:
pathMap
- the PathMap to which the expression should be addedpathMapNodeSet
- the PathMapNodeSet to which the paths embodied in this expression should be added- Returns:
- the pathMapNodeSet representing the points in the source document that are both reachable by this expression, and that represent possible results of this expression. For an expression that does navigation, it represents the end of the arc in the path map that describes the navigation route. For other expressions, it is the same as the input pathMapNode.
-
export
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
export
in interfaceExportAgent
- Specified by:
export
in classExpression
- Parameters:
out
- output destination- Throws:
XPathException
- if the export fails, for example if an expression is found that won't work in the target environment.
-
getSelect
Get the select expression- Returns:
- the select expression
-
setSelect
Set the select expression- Parameters:
select
- the select expression
-
setBindingSlot
public void setBindingSlot(int slot) Set the binding slot to be used (for the explicit or implicit reference to the mode). 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:
setBindingSlot
in 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 (for the explicit or implicit reference to the mode). This is the offset within the binding vector of the containing component where the actual target template is to be found.- Specified by:
getBindingSlot
in interfaceComponentInvocation
- Returns:
- the offset in the binding vector of the containing package where the target template can be found.
-
getStreamerName
Description copied from class:Expression
Get the (partial) name of a class that supports streaming of this kind of expression- Overrides:
getStreamerName
in 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
-
getElaborator
Make an elaborator for this expression- Overrides:
getElaborator
in classExpression
- Returns:
- an appropriate
Elaborator
-