net.sf.saxon.instruct
Class Block

java.lang.Object
  |
  +--net.sf.saxon.expr.ComputedExpression
        |
        +--net.sf.saxon.instruct.Instruction
              |
              +--net.sf.saxon.instruct.InstructionWithChildren
                    |
                    +--net.sf.saxon.instruct.Block
All Implemented Interfaces:
Container, Expression, InstructionInfoProvider, MappingFunction, java.io.Serializable, javax.xml.transform.SourceLocator

public class Block
extends InstructionWithChildren
implements MappingFunction

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

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.instruct.InstructionWithChildren
children
 
Fields inherited from class net.sf.saxon.expr.ComputedExpression
locationId, staticProperties
 
Fields inherited from interface net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
 
Constructor Summary
Block()
           
 
Method Summary
 void display(int level, NamePool pool, java.io.PrintStream out)
          Diagnostic print of expression structure.
 int getCardinality()
          Determine the cardinality of the expression
 ItemType getItemType()
          Determine the data type of the items returned by this expression
 SequenceIterator iterate(XPathContext context)
          Iterate over the results of all the child expressions
 java.lang.Object map(Item item, XPathContext context, java.lang.Object info)
          Map one item to a sequence.
 TailCall processLeavingTail(XPathContext context)
          ProcessLeavingTail: called to do the real work of this instruction.
protected  void promoteInst(PromotionOffer offer)
          Handle promotion offers, that is, non-local tree rewrites.
 Expression simplify(StaticContext env)
          Simplify an expression.
 
Methods inherited from class net.sf.saxon.instruct.InstructionWithChildren
analyze, displayChildren, getChildren, iterateSubExpressions, processChildren, processChildrenLeavingTail, setChildren
 
Methods inherited from class net.sf.saxon.instruct.Instruction
appendItem, assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, dynamicError, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, getImplementationMethod, getInstructionInfo, getInstructionNameCode, getSourceLocator, process, promote
 
Methods inherited from class net.sf.saxon.expr.ComputedExpression
adoptChildExpression, computeDependencies, computeStaticProperties, dynamicError, dynamicError, getColumnNumber, getConstructType, getDependencies, getExecutable, getIntrinsicDependencies, getLineNumber, getLocationId, getParentExpression, getPublicId, getSpecialProperties, getSystemId, markTailFunctionCalls, resetStaticProperties, setLocationId, setParentExpression, typeError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.xml.transform.SourceLocator
getColumnNumber, getLineNumber, getPublicId, getSystemId
 

Constructor Detail

Block

public Block()
Method Detail

getItemType

public final ItemType getItemType()
Determine the data type of the items returned by this expression

Specified by:
getItemType in interface Expression
Overrides:
getItemType in class Instruction
Returns:
the data type

getCardinality

public final int getCardinality()
Determine the cardinality of the expression

Specified by:
getCardinality in interface Expression
Overrides:
getCardinality in class ComputedExpression
Returns:
one of the values Cardinality.ONE_OR_MORE, Cardinality.ZERO_OR_MORE, Cardinality.EXACTLY_ONE, Cardinality.ZERO_OR_ONE, Cardinality.EMPTY. This default implementation returns ZERO_OR_MORE (which effectively gives no information).

simplify

public Expression simplify(StaticContext env)
                    throws XPathException
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression). The default implementation does nothing.

Specified by:
simplify in interface Expression
Overrides:
simplify in class InstructionWithChildren
Returns:
the simplified expression
Throws:
XPathException - if an error is discovered during expression rewriting

promoteInst

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

Overrides:
promoteInst in class InstructionWithChildren
Parameters:
offer - The type of rewrite being offered
Throws:
XPathException

display

public void display(int level,
                    NamePool pool,
                    java.io.PrintStream out)
Diagnostic print of expression structure. The expression is written to the System.err output stream

Specified by:
display in interface Expression
Parameters:
level - indentation level for this expression
out -
pool - NamePool used to expand any names appearing in the expression

processLeavingTail

public TailCall processLeavingTail(XPathContext context)
                            throws XPathException
Description copied from class: Instruction
ProcessLeavingTail: called to do the real work of this instruction. This method must be implemented in each subclass. The results of the instruction are written to the current Receiver, which can be obtained via the Controller.

Specified by:
processLeavingTail in class Instruction
Parameters:
context - The dynamic context of the transformation, giving access to the current node, the current variables, etc.
Returns:
null if the instruction has completed execution; or a TailCall indicating a function call or template call that is delegated to the caller, to be made after the stack has been unwound so as to save stack space.
XPathException

iterate

public SequenceIterator iterate(XPathContext context)
                         throws XPathException
Iterate over the results of all the child expressions

Specified by:
iterate in interface Expression
Overrides:
iterate in class Instruction
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

map

public java.lang.Object map(Item item,
                            XPathContext context,
                            java.lang.Object info)
                     throws XPathException
Map one item to a sequence.

Specified by:
map in interface MappingFunction
Parameters:
item - The item to be mapped. If context is supplied, this must be the same as context.currentItem().
context - The processing context. This is supplied only for mapping constructs that set the context node, position, and size. Otherwise it is null.
info - Arbitrary information supplied by the creator of the MappingIterator. It must be read-only and immutable for the duration of the iteration.
Returns:
either (a) a SequenceIterator over the sequence of items that the supplied input item maps to, or (b) an Item if it maps to a single item, or (c) null if it maps to an empty sequence.
XPathException