Class EvaluateInstr

java.lang.Object
net.sf.saxon.expr.Expression
net.sf.saxon.expr.instruct.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 Details Link icon

    • EvaluateInstr Link icon

      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 Details Link icon

    • setOptionsExpression Link icon

      public void setOptionsExpression(Expression options)
    • setActualParameters Link icon

      public void setActualParameters(WithParam[] params)
    • setDefaultXPathNamespace Link icon

      public void setDefaultXPathNamespace(NamespaceUri defaultXPathNamespace)
    • isInstruction Link icon

      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 Link icon

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

      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 Link icon

      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 Link icon

      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
    • computeCardinality Link icon

      protected int computeCardinality()
      Description copied from class: Expression
      Compute the static cardinality of this expression
      Specified by:
      computeCardinality in class Expression
      Returns:
      the computed cardinality, as one of the values StaticProperty.ALLOWS_ZERO_OR_ONE, StaticProperty.EXACTLY_ONE, StaticProperty.ALLOWS_ONE_OR_MORE, StaticProperty.ALLOWS_ZERO_OR_MORE. May also return StaticProperty.ALLOWS_ZERO if the result is known to be an empty sequence, or StaticProperty.ALLOWS_MANY if if is known to return a sequence of length two or more.
    • addToPathMap Link icon

      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 Link icon

      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 Link icon

      public 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
    • getImplementationMethod Link icon

      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 provided. This implementation provides the iterate() method natively.
      Specified by:
      getImplementationMethod in class Expression
      Returns:
      the implementation method, for example Expression.ITERATE_METHOD or Expression.EVALUATE_METHOD or Expression.PROCESS_METHOD
    • copy Link icon

      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 Link icon

      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 Link icon

      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.
    • getXpath Link icon

      public Expression getXpath()
    • setXpath Link icon

      public void setXpath(Expression xpath)
    • getContextItemExpr Link icon

      public Expression getContextItemExpr()
    • setContextItemExpr Link icon

      public void setContextItemExpr(Expression contextItemExpr)
    • getBaseUriExpr Link icon

      public Expression getBaseUriExpr()
    • setBaseUriExpr Link icon

      public void setBaseUriExpr(Expression baseUriExpr)
    • getNamespaceContextExpr Link icon

      public Expression getNamespaceContextExpr()
    • setNamespaceContextExpr Link icon

      public void setNamespaceContextExpr(Expression namespaceContextExpr)
    • getSchemaAwareExpr Link icon

      public Expression getSchemaAwareExpr()
    • setSchemaAwareExpr Link icon

      public void setSchemaAwareExpr(Expression schemaAwareExpr)
    • getActualParams Link icon

      public WithParam[] getActualParams()
    • setActualParams Link icon

      public void setActualParams(WithParam[] actualParams)
    • isActualParam Link icon

      public boolean isActualParam(StructuredQName name)
    • setDynamicParams Link icon

      public void setDynamicParams(Expression params)
    • getDynamicParams Link icon

      public Expression getDynamicParams()
    • getElaborator Link icon

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