Class CallTemplate

    • Constructor Detail

      • CallTemplate

        public CallTemplate​(NamedTemplate template,
                            StructuredQName calledTemplateName,
                            boolean useTailRecursion,
                            boolean inStreamable)
        Construct a CallTemplate instruction.
        Parameters:
        template - the template to be called. This is provisional, and applies only if the template is not overridden in another package; the template supplied will be the one with matching name in the same package. Null in the case of saxon:call-template, and also in the case where the supplied name is xsl:original
        calledTemplateName - the name of the template to be called; null in the case of saxon:call-template where this is established dynamically
        useTailRecursion - true if the call is potentially tail recursive where the name of the called template is to be calculated dynamically
        inStreamable - true if the call-template instruction appears within a construct that is declared streamable, for example a streamable template rule
    • Method Detail

      • 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
      • setTailRecursive

        public void setTailRecursive​(boolean tailRecursive)
        Mark the instruction as tail-recursive (or not)
        Parameters:
        tailRecursive - true if the call appears in a tail position
      • getCalledTemplateName

        public StructuredQName getCalledTemplateName()
        Get the name (QName) of the template being called
        Returns:
        the name of the target template
      • getSymbolicName

        public SymbolicName getSymbolicName()
        Get the symbolic name of the template being called. This is essentially the component kind (template) plus the QName of the target template
        Specified by:
        getSymbolicName in interface ComponentInvocation
        Returns:
        the symbolic name of the target template, or null in the case of saxon:call-template where the name is defined dynamically
      • getFixedTarget

        public Component getFixedTarget()
        Description copied from interface: ComponentInvocation
        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
      • 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
      • setTargetTemplate

        public void setTargetTemplate​(NamedTemplate target)
        Set the target template
        Parameters:
        target - the target template
      • getTargetTemplate

        public NamedTemplate getTargetTemplate()
        Get the target template
        Returns:
        the target template
      • usesTailRecursion

        public boolean usesTailRecursion()
        Ask whether this is a tail call
        Returns:
        true if this is a tail call
      • getInstructionNameCode

        public int getInstructionNameCode()
        Return the name of this instruction.
        Overrides:
        getInstructionNameCode in class Instruction
        Returns:
        a code identifying the instruction: typically but not always the fingerprint of a name in the XSLT namespace
      • setBindingSlot

        public void setBindingSlot​(int slot)
        Set the binding slot to be used. 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. 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.
      • 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
        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 contextItemType)
                            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
        contextItemType - 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)
      • computeCardinality

        protected int computeCardinality()
        Get the cardinality of the sequence returned by evaluating this instruction
        Overrides:
        computeCardinality in class Instruction
        Returns:
        the static cardinality
      • getItemType

        public ItemType getItemType()
        Get the item type of the items returned by evaluating this instruction
        Overrides:
        getItemType in class Instruction
        Returns:
        the static item type of the instruction
      • copy

        public Expression copy​(RebindingMap rebindings)
        Copy an expression. This makes a deep copy.
        Specified by:
        copy in class Expression
        Parameters:
        rebindings - Variables that need to be re-bound
        Returns:
        the copy of the original expression
      • 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
      • mayCreateNewNodes

        public final boolean mayCreateNewNodes()
        Determine whether this instruction creates new nodes. This implementation currently returns true unconditionally.
        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)
      • 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
      • process

        public void process​(Outputter output,
                            XPathContext context)
                     throws XPathException
        Process this instruction, without leaving any tail calls.
        Overrides:
        process in class Instruction
        Parameters:
        output - the destination for the result
        context - the dynamic context for this transformation
        Throws:
        XPathException - if a dynamic error occurs
      • getObjectName

        public StructuredQName getObjectName()
        Description copied from interface: Traceable
        Get a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc. This is used only where the name is known statically.
        Specified by:
        getObjectName in interface Traceable
        Overrides:
        getObjectName in class Expression
        Returns:
        the QName of the object declared or manipulated by this instruction or expression
      • export

        public void export​(ExpressionPresenter out)
                    throws XPathException
        Export 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 - the expression presenter used to display the structure
        Throws:
        XPathException - if the export fails, for example if an expression is found that won't work in the target environment.
      • toString

        public java.lang.String toString()
        Description copied from class: Expression

        The toString() method for an expression attempts to give a representation of the expression in an XPath-like form.

        For subclasses of Expression that represent XPath expressions, the result should always be a string that parses as an XPath 3.0 expression. The expression produced should be equivalent to the original making certain assumptions about the static context. In general the expansion will make no assumptions about namespace bindings, except that (a) the prefix "xs" is used to refer to the XML Schema namespace, and (b) the default function namespace is assumed to be the "fn" namespace.

        In the case of XSLT instructions and XQuery expressions, the toString() method gives an abstracted view of the syntax that is not designed in general to be parseable.

        Overrides:
        toString in class Expression
        Returns:
        a representation of the expression as a string
      • toShortString

        public java.lang.String toShortString()
        Description copied from class: Expression
        Produce a short string identifying the expression for use in error messages
        Overrides:
        toShortString in class Expression
        Returns:
        a short string, sufficient to identify the expression
      • 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
      • getElaborator

        public Elaborator getElaborator()
        Make an elaborator for this expression
        Overrides:
        getElaborator in class Expression
        Returns:
        a suitable elaborator