net.sf.saxon.instruct

Class While

public class While extends Instruction

Handler for saxon:while elements in stylesheet.
The saxon:while element has a mandatory attribute test, a boolean expression. The content is output repeatedly so long as the test condition is true.
Constructor Summary
While(Expression test, Expression action)
Method Summary
Expressioncopy()
Copy an expression.
booleancreatesNewNodes()
Determine whether this instruction creates new nodes.
voidexplain(ExpressionPresenter out)
Diagnostic print of expression structure.
ExpressiongetActionExpression()
Get the action expression (the content of the for-each)
intgetInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes
ItemTypegetItemType(TypeHierarchy th)
Get the item type of the items returned by evaluating this instruction
booleanhasLoopingSubexpression(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
Iterator<Expression>iterateSubExpressions()
Get all the XPath expressions associated with this instruction (in XSLT terms, the expression present on attributes of the instruction, as distinct from the child instructions in a sequence construction)
Expressionoptimize(ExpressionVisitor visitor, ItemType contextItemType)
TailCallprocessLeavingTail(XPathContext context)
protected voidpromoteInst(PromotionOffer offer)
Handle promotion offers, that is, non-local tree rewrites.
booleanreplaceSubExpression(Expression original, Expression replacement)
Replace one subexpression by a replacement subexpression
Expressionsimplify(ExpressionVisitor visitor)
Simplify an expression.
ExpressiontypeCheck(ExpressionVisitor visitor, ItemType contextItemType)

Constructor Detail

While

public While(Expression test, Expression action)

Method Detail

copy

public Expression copy()
Copy an expression. This makes a deep copy.

Returns: the copy of the original expression

createsNewNodes

public final boolean createsNewNodes()
Determine whether this instruction creates new nodes. This implementation returns true if the "action" creates new nodes. (Nodes created by the condition can't contribute to the result).

explain

public void explain(ExpressionPresenter out)
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.

getActionExpression

public Expression getActionExpression()
Get the action expression (the content of the for-each)

getInstructionNameCode

public int getInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes

Returns: the string "saxon:while"

getItemType

public ItemType getItemType(TypeHierarchy th)
Get the item type of the items returned by evaluating this instruction

Parameters: th the type hierarchy cache

Returns: the static item type of the instruction

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

Parameters: child the immediate subexpression

Returns: true if the child expression is evaluated repeatedly

iterateSubExpressions

public Iterator<Expression> iterateSubExpressions()
Get all the XPath expressions associated with this instruction (in XSLT terms, the expression present on attributes of the instruction, as distinct from the child instructions in a sequence construction)

optimize

public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType)

processLeavingTail

public TailCall processLeavingTail(XPathContext context)

promoteInst

protected void promoteInst(PromotionOffer offer)
Handle promotion offers, that is, non-local tree rewrites.

Parameters: offer The type of rewrite being offered

Throws: XPathException

replaceSubExpression

public boolean replaceSubExpression(Expression original, Expression replacement)
Replace one subexpression by a replacement subexpression

Parameters: original the original subexpression replacement the replacement subexpression

Returns: true if the original subexpression is found

simplify

public Expression simplify(ExpressionVisitor visitor)
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression).

Parameters: visitor an expression visitor

Returns: the simplified expression

Throws: XPathException if an error is discovered during expression rewriting

typeCheck

public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType)