Class ApplyTemplates

    • Field Detail

      • useCurrentMode

        protected boolean useCurrentMode
      • _useTailRecursion

        protected boolean _useTailRecursion
      • mode

        protected Mode mode
      • implicitSelect

        protected boolean implicitSelect
      • inStreamableConstruct

        protected boolean inStreamableConstruct
    • Constructor Detail

      • 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 expression
        useCurrentMode - true if mode="#current" was specified
        useTailRecursion - true if this instruction is the last in its template
        implicitSelect - 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 rule
        mode - the mode specified on apply-templates
        ruleManager - the rule manager
    • Method Detail

      • init

        protected void init​(Expression select,
                            boolean useCurrentMode,
                            boolean useTailRecursion,
                            Mode mode)
      • setMode

        public void setMode​(SimpleMode target)
        Set the mode to be used.
        Parameters:
        target - the attribute set to be used
      • setSeparatorExpression

        public void setSeparatorExpression​(Expression separator)
        Set the separator expression (Saxon extension)
        Parameters:
        separator - the separator expression
      • getSeparatorExpression

        public Expression getSeparatorExpression()
      • getActualParams

        public WithParam[] getActualParams()
        Get the actual parameters passed to the called template
        Specified by:
        getActualParams in interface ITemplateCall
        Returns:
        the non-tunnel parameters
      • getTunnelParams

        public WithParam[] getTunnelParams()
        Get the tunnel parameters passed to the called template
        Specified by:
        getTunnelParams in interface ITemplateCall
        Returns:
        the tunnel parameters
      • setActualParams

        public void setActualParams​(WithParam[] params)
      • setTunnelParams

        public void setTunnelParams​(WithParam[] params)
      • operands

        public java.lang.Iterable<Operand> 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 class Instruction
        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 class Instruction
        Returns:
        a code identifying the instruction: typically but not always the fingerprint of a name in the XSLT namespace
      • simplify

        public Expression simplify()
                            throws XPathException
        Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression).
        Overrides:
        simplify in class Expression
        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 class Expression
        Parameters:
        visitor - an expression visitor
        contextInfo - 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 class Expression
        Parameters:
        visitor - an expression visitor
        contextInfo - 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 to Type.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 class Expression
        Returns:
        an integer containing bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
      • copy

        public Expression copy​(RebindingMap rebindings)
        Copy an expression. This makes a deep copy.
        Specified by:
        copy in class Expression
        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 class Instruction
        Returns:
        true if the instruction creates new nodes under some input conditions (or if it can't be proved that it doesn't)
      • getTargetMode

        public Component.M getTargetMode​(XPathContext context)
        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

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

        public Mode getMode()
        Get the Mode
        Returns:
        the mode, or null if mode="#current" was specified
      • getFixedTarget

        public Component 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 interface ComponentInvocation
        Returns:
        the bound component if the binding has been fixed
      • getSymbolicName

        public SymbolicName getSymbolicName()
        Get the symbolic name of the mode that this invocation references
        Specified by:
        getSymbolicName in interface ComponentInvocation
        Returns:
        the symbolic name of the mode used by this instructon, or null if the instruction uses mode="#current"
      • addToPathMap

        public PathMap.PathMapNodeSet addToPathMap​(PathMap pathMap,
                                                   PathMap.PathMapNodeSet pathMapNodeSet)
        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 class Expression
        Parameters:
        pathMap - the PathMap to which the expression should be added
        pathMapNodeSet - 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

        public void export​(ExpressionPresenter out)
                    throws XPathException
        Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
        Specified by:
        export in interface ExportAgent
        Specified by:
        export in class Expression
        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

        public Expression getSelect()
        Get the select expression
        Returns:
        the select expression
      • setSelect

        public void setSelect​(Expression select)
        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 interface ComponentInvocation
        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 interface ComponentInvocation
        Returns:
        the offset in the binding vector of the containing package where the target template can be found.
      • getStreamerName

        public java.lang.String getStreamerName()
        Description copied from class: Expression
        Get the (partial) name of a class that supports streaming of this kind of expression
        Overrides:
        getStreamerName in class Expression
        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