Class EvaluateInstr

  • All Implemented Interfaces:
    ExportAgent, Locatable, IdentityComparable, Traceable

    public final class EvaluateInstr
    extends Expression
    An EvaluateInstr is the compiled form of an xsl:evaluate instruction

    The implementation maintains a cache of compiled expressions, provided that the namespace context is not constructed dynamically. The cache is an LRU cache with a fixed size of 100 entries. This is to avoid uncontrolled use of memory when the XPath expressions are completely dynamic and each one is unique.

    • Constructor Detail

      • EvaluateInstr

        public EvaluateInstr​(Expression xpath,
                             SequenceType requiredType,
                             Expression contextItemExpr,
                             Expression baseUriExpr,
                             Expression namespaceContextExpr,
                             Expression schemaAwareExpr)
        Create an xsl:evaluate instruction
        Parameters:
        xpath - The expression that returns the string that is to be parsed as an XPath expression
        requiredType - the required type of the result of evaluating the XPath expression
        contextItemExpr - The expression that delivers the context item
        baseUriExpr - the expression whose value is used as the static base URI of the XPath expression
        namespaceContextExpr - the expression that delivers a node whose namespace context provides the static namespace context for the XPath expression
        schemaAwareExpr - an expression whose value is true if the XPath expression is to be treated as schema aware, or false otherwise
    • Method Detail

      • setOptionsExpression

        public void setOptionsExpression​(Expression options)
      • setActualParameters

        public void setActualParameters​(WithParam[] params)
      • setDefaultXPathNamespace

        public void setDefaultXPathNamespace​(NamespaceUri defaultXPathNamespace)
      • isInstruction

        public boolean isInstruction()
        Ask whether this expression is an instruction. In XSLT streamability analysis this is used to distinguish constructs corresponding to XSLT instructions from other constructs, typically XPath expressions.
        Overrides:
        isInstruction in class Expression
        Returns:
        true (if this construct exists at all in an XSLT environment, then it represents an instruction)
      • importSchemaNamespace

        public void importSchemaNamespace​(NamespaceUri ns)
        Add an imported schema namespace
        Parameters:
        ns - the namespace to be imported ("" for the non-namespace)
      • typeCheck

        public Expression typeCheck​(ExpressionVisitor visitor,
                                    ContextItemStaticInfo contextInfo)
                             throws XPathException
        Type-check the expression
        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)
      • getItemType

        public final ItemType getItemType()
        Determine the data type of the items returned by this expression
        Specified by:
        getItemType in class Expression
        Returns:
        the data type
      • 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 set of nodes in the path map that are affected
        Returns:
        the pathMapNode representing the focus established by this expression, in the case where this expression is the first operand of a path expression or filter 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.
      • 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
      • 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.

        Overrides:
        operands in class Expression
        Returns:
        an iterator containing the sub-expressions of this expression
      • 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
      • iterate

        public SequenceIterator iterate​(XPathContext context)
                                 throws XPathException
        Description copied from class: Expression
        Return an Iterator to iterate over the values of a sequence. The value of every expression can be regarded as a sequence, so this method is supported for all expressions. This default implementation handles iteration for expressions that return singleton values: for non-singleton expressions, the subclass must provide its own implementation.
        Overrides:
        iterate in class Expression
        Parameters:
        context - supplies the context for evaluation
        Returns:
        a SequenceIterator that can be used to iterate over the result of the expression
        Throws:
        XPathException - if any dynamic error occurs evaluating the expression
      • 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 - 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.
      • setXpath

        public void setXpath​(Expression xpath)
      • getContextItemExpr

        public Expression getContextItemExpr()
      • setContextItemExpr

        public void setContextItemExpr​(Expression contextItemExpr)
      • getBaseUriExpr

        public Expression getBaseUriExpr()
      • setBaseUriExpr

        public void setBaseUriExpr​(Expression baseUriExpr)
      • getNamespaceContextExpr

        public Expression getNamespaceContextExpr()
      • setNamespaceContextExpr

        public void setNamespaceContextExpr​(Expression namespaceContextExpr)
      • getSchemaAwareExpr

        public Expression getSchemaAwareExpr()
      • setSchemaAwareExpr

        public void setSchemaAwareExpr​(Expression schemaAwareExpr)
      • getActualParams

        public WithParam[] getActualParams()
      • setActualParams

        public void setActualParams​(WithParam[] actualParams)
      • setDynamicParams

        public void setDynamicParams​(Expression params)
      • getDynamicParams

        public Expression getDynamicParams()