public class ForEach extends Instruction implements ContextMappingFunction, ContextSwitchingExpression
| Modifier and Type | Field and Description |
|---|---|
protected Operand |
actionOp |
protected boolean |
containsTailCall |
protected Operand |
selectOp |
protected Operand |
threadsOp |
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD| Constructor and Description |
|---|
ForEach(Expression select,
Expression action)
Create an xsl:for-each instruction
|
ForEach(Expression select,
Expression action,
boolean containsTailCall,
Expression threads)
Create an xsl:for-each instruction
|
| Modifier and Type | Method and Description |
|---|---|
PathMap.PathMapNodeSet |
addToPathMap(PathMap pathMap,
PathMap.PathMapNodeSet pathMapNodeSet)
Add a representation of this expression to a PathMap.
|
void |
checkPermittedContents(SchemaType parentType,
boolean whole)
Check that any elements and attributes constructed or returned by this expression are acceptable
in the content model of a given complex type.
|
int |
computeSpecialProperties()
Get the static properties of this expression (other than its type).
|
Expression |
copy()
Copy an expression.
|
boolean |
createsNewNodes()
Determine whether this instruction creates new nodes.
|
protected void |
explainThreads(ExpressionPresenter out) |
void |
export(ExpressionPresenter out)
Diagnostic print of expression structure.
|
Expression |
getAction()
Get the action expression (in XSLT, the body of the xsl:for-each instruction
|
Expression |
getActionExpression()
Get the subexpression that is evaluated in the new context
|
ExpressionCompiler |
getExpressionCompiler()
Return the compiler of the ForEach expression
|
String |
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.
|
int |
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
|
int |
getInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes
|
ItemType |
getItemType()
Determine the data type of the items returned by this expression
|
Expression |
getNumberOfThreadsExpression()
Get the number of threads requested
|
Expression |
getSelect()
Get the select expression
|
Expression |
getSelectExpression()
Get the select expression
|
ForEachAdjunct |
getStreamingAdjunct()
Get a class that supports streamed evaluation of this expression
|
Expression |
getThreads()
Get the expression used to determine how many threads to use when multi-threading
|
SequenceIterator |
iterate(XPathContext context)
Return an Iterator to iterate over the values of the sequence.
|
SequenceIterator |
map(XPathContext context)
Map one item to a sequence.
|
Iterable<Operand> |
operands()
Get the operands of this expression
|
Expression |
optimize(ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo)
Perform optimisation of an expression and its subexpressions.
|
TailCall |
processLeavingTail(XPathContext context)
ProcessLeavingTail: called to do the real work of this instruction.
|
protected void |
promoteChildren(PromotionOffer offer)
Handle promotion offers, that is, non-local tree rewrites.
|
void |
setAction(Expression action)
Set the action expression (in XSLT, the body of the xsl:for-each instruction)
|
void |
setActionExpression(Expression action)
Set the action expression
|
void |
setSelect(Expression select)
Set the select expression
|
void |
setSelectExpression(Expression select)
Set the select expression
|
void |
setThreads(Expression threads)
Set the expression used to determine how many threads to use when multi-threading
|
String |
toShortString()
Produce a short string identifying the expression for use in error messages
|
String |
toString()
The toString() method for an expression attempts to give a representation of the expression
in an XPath-like form.
|
Expression |
typeCheck(ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo)
Perform type checking of an expression and its subexpressions.
|
Expression |
unordered(boolean retainAllNodes,
boolean forStreaming)
Replace this expression by a simpler expression that delivers the results without regard
to order.
|
assembleParams, assembleTunnelParams, computeCardinality, dynamicError, evaluateAsString, evaluateItem, getConstructType, getInstructionName, getNetCost, getSourceLocator, isXSLT, main, process, toStreamingPatternadoptChildExpression, checkedOperands, checkForUpdatingSubexpressions, clearStreamabilityData, computeDependencies, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getHostLanguage, getIntegerBounds, getIntrinsicDependencies, getLocation, getObjectName, getPackageData, getParentExpression, getPosture, getPostureAndSweepIfKnown, getProperties, getProperty, getRetainedStaticContext, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStreamability, getSweep, getSystemId, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isCallOnSystemFunction, isIdentical, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterateEvents, makeStreamingAdjunct, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, optimizeForType, promote, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setFiltered, setFlattened, setLocation, setParentExpression, setPostureAndSweep, setRetainedStaticContext, setRetainedStaticContextLocally, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, typeCheckChildren, typeErrorprotected boolean containsTailCall
protected Operand selectOp
protected Operand actionOp
protected Operand threadsOp
public ForEach(Expression select, Expression action)
select - the select expressionaction - the body of the xsl:for-each looppublic ForEach(Expression select, Expression action, boolean containsTailCall, Expression threads)
select - the select expressionaction - the body of the xsl:for-each loopcontainsTailCall - true if the body of the loop contains a tail call on the containing functionthreads - if >1 causes multithreaded execution (Saxon-EE only)public Expression getSelect()
public void setSelect(Expression select)
select - the select expression of the for-eachpublic Expression getAction()
public void setAction(Expression action)
action - the action expressionpublic Expression getThreads()
public void setThreads(Expression threads)
threads - the saxon:threads expression if present, or null otherwisepublic Iterable<Operand> operands()
operands in class Instructionpublic int getInstructionNameCode()
getInstructionNameCode in class Instructionpublic Expression getSelectExpression()
getSelectExpression in interface ContextSwitchingExpressionpublic void setSelectExpression(Expression select)
select - the select expressionpublic void setActionExpression(Expression action)
action - the select expressionpublic Expression getActionExpression()
getActionExpression in interface ContextSwitchingExpressionpublic Expression getNumberOfThreadsExpression()
public final ItemType getItemType()
getItemType in class Instructionpublic final boolean createsNewNodes()
createsNewNodes in class Instructionpublic Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
ExpressionThis 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.
typeCheck in class Expressionvisitor - an expression visitorcontextInfo - Information available statically about the context item: whether it is (possibly)
absent; its static type; its streaming posture.XPathException - if an error is discovered during this phase
(typically a type error)public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
ExpressionThis 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.
optimize in class Expressionvisitor - an expression visitorcontextInfo - 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_TYPEXPathException - if an error is discovered during this phase
(typically a type error)public Expression unordered(boolean retainAllNodes, boolean forStreaming) throws XPathException
unordered in class ExpressionretainAllNodes - set to true if the result must contain exactly the same nodes as the
original; set to false if the result can eliminate (or introduce) duplicates.forStreaming - set to true if optimizing for streamingXPathException - if the rewrite failspublic PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
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.
addToPathMap in class ExpressionpathMap - the PathMap to which the expression should be addedpathMapNodeSet - the set of nodes in the path map that are affectedpublic Expression copy()
copy in class Expressionpublic int computeSpecialProperties()
computeSpecialProperties in class Instructionprotected void promoteChildren(PromotionOffer offer) throws XPathException
promoteChildren in class Instructionoffer - The type of rewrite being offeredXPathExceptionpublic int getImplementationMethod()
getImplementationMethod in class InstructionExpression.ITERATE_METHOD or Expression.EVALUATE_METHOD or
Expression.PROCESS_METHODpublic void checkPermittedContents(SchemaType parentType, boolean whole) throws XPathException
checkPermittedContents in class ExpressionparentType - the "given complex type": the method is checking that the nodes returned by this
expression are acceptable members of the content model of this typewhole - if true, we want to check that the value of this expression satisfies the content model
as a whole; if false we want to check that the value of the expression is acceptable as one part
of the contentXPathException - if the value delivered by this expression cannot be part of the content model
of the given typepublic TailCall processLeavingTail(XPathContext context) throws XPathException
InstructionprocessLeavingTail in interface TailCallReturnerprocessLeavingTail in class Instructioncontext - The dynamic context of the transformation, giving access to the current node,
the current variables, etc.XPathException - if a dynamic error occurs during the evaluation
of the instructionpublic SequenceIterator iterate(XPathContext context) throws XPathException
iterate in class Instructioncontext - supplies the context for evaluationXPathException - if any dynamic error occurs evaluating the
expressionpublic SequenceIterator map(XPathContext context) throws XPathException
map in interface ContextMappingFunctioncontext - The processing context. The item to be mapped is the context item identified
from this context: the values of position() and last() also relate to the set of items being mappedXPathException - if a dynamic error is detectedpublic void export(ExpressionPresenter out)
export in class Expressionout - the expression presenter used to display the structureprotected void explainThreads(ExpressionPresenter out)
public String toString()
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
toString in class Expressionpublic String toShortString()
ExpressiontoShortString in class Expressionpublic String getExpressionName()
getExpressionName in class Instructionpublic ExpressionCompiler getExpressionCompiler()
getExpressionCompiler in class Expressionpublic ForEachAdjunct getStreamingAdjunct()
getStreamingAdjunct in class ExpressionCopyright (c) 2004-2014 Saxonica Limited. All rights reserved.