Class EvaluateInstr
- All Implemented Interfaces:
ExportAgent,Locatable,IdentityComparable,Traceable
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.
-
Field Summary
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
ConstructorsConstructorDescriptionEvaluateInstr(Expression xpath, SequenceType requiredType, Expression contextItemExpr, Expression baseUriExpr, Expression namespaceContextExpr, Expression schemaAwareExpr) Create an xsl:evaluate instruction -
Method Summary
Modifier and TypeMethodDescriptionaddToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet) Add a representation of this expression to a PathMap.protected intCompute the static cardinality of this expressioncopy(RebindingMap rebindings) Copy an expression.voidDiagnostic print of expression structure.Make an elaborator for this expressionintAn implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().intDetermine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.final ItemTypeDetermine the data type of the items returned by this expressiongetXpath()voidAdd an imported schema namespacebooleanisActualParam(StructuredQName name) booleanAsk whether this expression is an instruction.iterate(XPathContext context) Return an Iterator to iterate over the values of a sequence.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 contextItemType) Perform optimisation of an expression and its subexpressions.voidsetActualParameters(WithParam[] params) voidsetActualParams(WithParam[] actualParams) voidsetBaseUriExpr(Expression baseUriExpr) voidsetContextItemExpr(Expression contextItemExpr) voidsetDefaultXPathNamespace(NamespaceUri defaultXPathNamespace) voidsetDynamicParams(Expression params) voidsetNamespaceContextExpr(Expression namespaceContextExpr) voidsetOptionsExpression(Expression options) voidsetSchemaAwareExpr(Expression schemaAwareExpr) voidsetXpath(Expression xpath) typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) Type-check the expressionMethods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeSpecialProperties, computeStaticProperties, dispatchTailCall, dynamicError, effectiveBooleanValue, equals, evaluateAsString, evaluateItem, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExpressionName, getExtraProperty, getIntegerBounds, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, makeElaborator, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, toPattern, toShortString, toString, typeCheckChildren, typeError, unordered, verifyParentPointers, withLocationMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
Constructor Details
-
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 expressionrequiredType- the required type of the result of evaluating the XPath expressioncontextItemExpr- The expression that delivers the context itembaseUriExpr- the expression whose value is used as the static base URI of the XPath expressionnamespaceContextExpr- the expression that delivers a node whose namespace context provides the static namespace context for the XPath expressionschemaAwareExpr- an expression whose value is true if the XPath expression is to be treated as schema aware, or false otherwise
-
-
Method Details
-
setOptionsExpression
-
setActualParameters
-
setDefaultXPathNamespace
-
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:
isInstructionin classExpression- Returns:
- true (if this construct exists at all in an XSLT environment, then it represents an instruction)
-
importSchemaNamespace
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:
typeCheckin 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 contextItemType) throws XPathException Description copied from class:ExpressionPerform 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:
optimizein classExpression- Parameters:
visitor- an expression visitorcontextItemType- 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)
-
getItemType
Determine the data type of the items returned by this expression- Specified by:
getItemTypein classExpression- Returns:
- the data type
-
computeCardinality
protected int computeCardinality()Description copied from class:ExpressionCompute the static cardinality of this expression- Specified by:
computeCardinalityin classExpression- 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 returnStaticProperty.ALLOWS_ZEROif the result is known to be an empty sequence, orStaticProperty.ALLOWS_MANYif if is known to return a sequence of length two or more.
-
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:
addToPathMapin classExpression- Parameters:
pathMap- the PathMap to which the expression should be addedpathMapNodeSet- 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:ExpressionDetermine 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:
getIntrinsicDependenciesin classExpression- Returns:
- an integer containing bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
-
operands
Description copied from class:ExpressionGet 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:
operandsin classExpression- Returns:
- an iterator containing the sub-expressions of this expression
-
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 provided. This implementation provides the iterate() method natively.- Specified by:
getImplementationMethodin classExpression- Returns:
- the implementation method, for example
Expression.ITERATE_METHODorExpression.EVALUATE_METHODorExpression.PROCESS_METHOD
-
copy
Copy an expression. This makes a deep copy.- Specified by:
copyin 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
-
iterate
Description copied from class:ExpressionReturn 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:
iteratein classExpression- 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
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
exportin interfaceExportAgent- Specified by:
exportin classExpression- 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
-
setXpath
-
getContextItemExpr
-
setContextItemExpr
-
getBaseUriExpr
-
setBaseUriExpr
-
getNamespaceContextExpr
-
setNamespaceContextExpr
-
getSchemaAwareExpr
-
setSchemaAwareExpr
-
getActualParams
-
setActualParams
-
isActualParam
-
setDynamicParams
-
getDynamicParams
-
getElaborator
Make an elaborator for this expression- Overrides:
getElaboratorin classExpression- Returns:
- an appropriate
Elaborator
-