A ForExpression maps an expression over a sequence.
This version works with range variables, it doesn't change the context information
checkPermittedContents
public void checkPermittedContents(SchemaType parentType,
StaticContext env,
boolean whole)
throws XPathException
Check that any elements and attributes constructed or returned by this expression are acceptable
in the content model of a given complex type. It's always OK to say yes, since the check will be
repeated at run-time. The process of checking element and attribute constructors against the content
model of a complex type also registers the type of content expected of those constructors, so the
static validation can continue recursively.
- checkPermittedContents in interface Expression
computeCardinality
public int computeCardinality()
Determine the static cardinality of the expression
- computeCardinality in interface Expression
convertWhereToPredicate
public Expression convertWhereToPredicate(ExpressionVisitor visitor,
ItemType contextItemType)
throws XPathException
Convert where clause, if possible, to a predicate.
visitor
- the expression visitorcontextItemType
- the item type of the context item
- the converted expression if modified, or null otherwise
copy
public Expression copy()
Copy an expression. This makes a deep copy.
- copy in interface Expression
- the copy of the original expression
explain
public void explain(ExpressionPresenter out)
Diagnostic print of expression structure. The abstract expression tree
is written to the supplied output destination.
- explain in interface Expression
getConstructType
protected int getConstructType()
Get the type of this expression for use in tracing and diagnostics
- getConstructType in interface Expression
- the type of expression, as enumerated in class
Location
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 both iterate() and
process() methods natively.
- getImplementationMethod in interface Expression
getItemType
public ItemType getItemType(TypeHierarchy th)
Determine the data type of the items returned by the expression, if possible
- getItemType in interface Expression
th
- the type hierarchy cache
- one of the values Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE,
or Type.ITEM (meaning not known in advance)
getPositionVariableName
public StructuredQName getPositionVariableName()
Get the name of the position variable
- the name of the position variable ("at $p") if there is one, or null if not
getRequiredSlots
public int getRequiredSlots()
Get the number of slots required.
- getRequiredSlots in interface Assignation
- normally 1, except for a FOR expression with an AT clause, where it is 2.
hasLoopingSubexpression
public boolean hasLoopingSubexpression(Expression child)
Given an expression that is an immediate child of this expression, test whether
the evaluation of the parent expression causes the child expression to be
evaluated repeatedly
- hasLoopingSubexpression in interface Expression
child
- the immediate subexpression
- true if the child expression is evaluated repeatedly
iterateEvents
public EventIterator iterateEvents(XPathContext context)
throws XPathException
Deliver the result of the expression as a sequence of events.
- iterateEvents in interface Expression
context
- The dynamic evaluation context
- the result of the expression as an iterator over a sequence of PullEvent objects
XPathException
- if a dynamic error occurs during expression evaluation
markTailFunctionCalls
public int markTailFunctionCalls(StructuredQName qName,
int arity)
Mark tail function calls: only possible if the for expression iterates zero or one times.
(This arises in XSLT/XPath, which does not have a LET expression, so FOR gets used instead)
- markTailFunctionCalls in interface Expression
setPositionVariable
public void setPositionVariable(PositionVariable decl)
Set the reference to the position variable (XQuery only)
decl
- the range variable declaration for the position variable
setSlotNumber
public void setSlotNumber(int nr)
Set the slot number for the range variable
- setSlotNumber in interface Assignation
nr
- the slot number allocated to the range variable on the local stack frame.
This implicitly allocates the next slot number to the position variable if there is one.