net.sf.saxon.instruct

Class Block

Implemented Interfaces:
SourceLocator, EvaluableItem, InstructionInfoProvider, SequenceIterable, Serializable, SourceLocator, TailCallReturner

public class Block
extends Instruction

Implements an imaginary xsl:block instruction which simply evaluates its contents. Used for top-level templates, xsl:otherwise, etc.

Field Summary

Fields inherited from class net.sf.saxon.expr.Expression

EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD, locationId, staticProperties

Constructor Summary

Block()
Create an empty block

Method Summary

void
checkPermittedContents(SchemaType parentType, StaticContext env, 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.
Expression
copy()
Copy an expression.
boolean
createsNewNodes()
Determine whether this instruction creates new nodes.
void
explain(ExpressionPresenter out)
Diagnostic print of expression structure.
int
getCardinality()
Determine the cardinality of the expression
Expression[]
getChildren()
Get the children of this instruction
int
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
ItemType
getItemType(TypeHierarchy th)
Determine the data type of the items returned by this expression
SequenceIterator
iterate(XPathContext context)
Iterate over the results of all the child expressions
EventIterator
iterateEvents(XPathContext context)
Get an EventIterator over the results of all the child expressions
Iterator
iterateSubExpressions()
static Expression
makeBlock(List list)
Static factory method to create a block from a list of expressions
static Expression
makeBlock(Expression e1, Expression e2)
Static factory method to create a block.
Expression
optimize(ExpressionVisitor visitor, ItemType contextItemType)
TailCall
processLeavingTail(XPathContext context)
protected void
promoteInst(PromotionOffer offer)
Handle promotion offers, that is, non-local tree rewrites.
boolean
replaceSubExpression(Expression original, Expression replacement)
Replace one subexpression by a replacement subexpression
void
setChildren(Expression[] children)
Set the children of this instruction
Expression
simplify(ExpressionVisitor visitor)
Simplify an expression.
Expression
typeCheck(ExpressionVisitor visitor, ItemType contextItemType)

Methods inherited from class net.sf.saxon.instruct.Instruction

assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, createsNewNodes, dynamicError, evaluateAsString, evaluateItem, getImplementationMethod, getInstructionInfo, getInstructionNameCode, getItemType, getSourceLocator, isXSLT, iterate, process, processLeavingTail, promote, promoteInst, simplify

Methods inherited from class net.sf.saxon.expr.Expression

addToPathMap, adoptChildExpression, checkPermittedContents, computeCardinality, computeDependencies, computeSpecialProperties, computeStaticProperties, copy, display, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, explain, explain, findParentOf, getCardinality, getColumnNumber, getConstructType, getContainer, getDependencies, getExecutable, getHostLanguage, getImplementationMethod, getInstructionInfo, getIntrinsicDependencies, getItemType, getLineNumber, getLocationId, getLocationProvider, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasLoopingSubexpression, implementsStaticTypeCheck, iterate, iterateEvents, iterateSubExpressions, markTailFunctionCalls, optimize, process, promote, replaceSubExpression, resetLocalStaticProperties, setContainer, setFiltered, setFlattened, setLocationId, simplify, staticTypeCheck, suppressValidation, toString, typeCheck, typeError

Constructor Details

Block

public Block()
Create an empty block

Method Details

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.
Overrides:
checkPermittedContents in interface Expression

copy

public Expression copy()
Copy an expression. This makes a deep copy.
Overrides:
copy in interface Expression
Returns:
the copy of the original expression

createsNewNodes

public final boolean createsNewNodes()
Determine whether this instruction creates new nodes. This implementation returns true if any child instruction returns true.
Overrides:
createsNewNodes in interface Instruction

explain

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

getCardinality

public final int getCardinality()
Determine the cardinality of the expression
Overrides:
getCardinality in interface Expression

getChildren

public Expression[] getChildren()
Get the children of this instruction
Returns:
the children of this instruction, as an array of Instruction objects. May return either a zero-length array or null if there are no children

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.
Overrides:
getImplementationMethod in interface Instruction

getItemType

public final ItemType getItemType(TypeHierarchy th)
Determine the data type of the items returned by this expression
Overrides:
getItemType in interface Instruction
Parameters:
th - the type hierarchy cache
Returns:
the data type

iterate

public SequenceIterator iterate(XPathContext context)
            throws XPathException
Iterate over the results of all the child expressions
Specified by:
iterate in interface SequenceIterable
Overrides:
iterate in interface Instruction

iterateEvents

public EventIterator iterateEvents(XPathContext context)
            throws XPathException
Get an EventIterator over the results of all the child expressions
Overrides:
iterateEvents in interface Expression
Parameters:
context - the XPath dynamic context
Returns:
an EventIterator

iterateSubExpressions

public Iterator iterateSubExpressions()
Overrides:
iterateSubExpressions in interface Expression

makeBlock

public static Expression makeBlock(List list)
Static factory method to create a block from a list of expressions
Parameters:
list - the list of expressions making up this block. The members of the List must be instances of Expression
Returns:
a Block containing the two subexpressions, and if either of them is a block, it will have been collapsed to create a flattened sequence

makeBlock

public static Expression makeBlock(Expression e1,
                                   Expression e2)
Static factory method to create a block. If one of the arguments is already a block, the contents will be merged into a new composite block
Parameters:
e1 - the first subexpression (child) of the block
e2 - the second subexpression (child) of the block
Returns:
a Block containing the two subexpressions, and if either of them is a block, it will have been collapsed to create a flattened sequence

optimize

public Expression optimize(ExpressionVisitor visitor,
                           ItemType contextItemType)
            throws XPathException
Overrides:
optimize in interface Expression

processLeavingTail

public TailCall processLeavingTail(XPathContext context)
            throws XPathException
Specified by:
processLeavingTail in interface TailCallReturner
Overrides:
processLeavingTail in interface Instruction

promoteInst

protected void promoteInst(PromotionOffer offer)
            throws XPathException
Handle promotion offers, that is, non-local tree rewrites.
Overrides:
promoteInst in interface Instruction
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
Overrides:
replaceSubExpression in interface Expression
Parameters:
original - the original subexpression
replacement - the replacement subexpression
Returns:
true if the original subexpression is found

setChildren

public void setChildren(Expression[] children)
Set the children of this instruction
Parameters:
children - The instructions that are children of this instruction

simplify

public Expression simplify(ExpressionVisitor visitor)
            throws XPathException
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression). The default implementation does nothing.
Overrides:
simplify in interface Instruction
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)
            throws XPathException
Overrides:
typeCheck in interface Expression