net.sf.saxon.instruct
Class Instruction

java.lang.Object
  extended bynet.sf.saxon.instruct.Instruction
All Implemented Interfaces:
java.io.Serializable, javax.xml.transform.SourceLocator
Direct Known Subclasses:
AnalyzeString, ApplyImports, ApplyTemplates, AttributeSet, Block, CallTemplate, Choose, DeferredError, Doctype, Executable, ExprInstruction, ForEach, ForEachGroup, FunctionInstr, GeneralVariable, Message, NextMatch, NumberInstruction, ResultDocument, Template, While

public abstract class Instruction
extends java.lang.Object
implements java.io.Serializable, javax.xml.transform.SourceLocator

Abstract superclass for all instructions in the compiled stylesheet. This represents a compiled instruction, and as such, the minumum information is retained from the original stylesheet.
Note: this class implements SourceLocator.

See Also:
Serialized Form

Field Summary
protected  Instruction[] children
           
 
Constructor Summary
Instruction()
          Constructor
 
Method Summary
protected  ParameterSet assembleParams(XPathContext context, WithParam[] actualParams)
          Assemble a ParameterSet.
protected  ParameterSet assembleTunnelParams(XPathContext context, WithParam[] actualParams)
          Assemble a ParameterSet.
 Instruction[] getChildren()
          Get the children of this instruction
 int getColumnNumber()
           
 InstructionDetails getInstructionDetails(Controller controller)
          Contruct details of an InstructionInfo for use by the TraceListener.
 java.lang.String getInstructionName()
           
 int getLineNumber()
          Get the line number of the source stylesheet instruction within its module.
 java.lang.String getPublicId()
           
 SequenceType getResultType()
          Get the static type of the value returned by the instruction
 java.lang.String getSystemId()
           
 java.lang.String getSystemId(Executable exec)
          Get the system ID of the source stylesheet module containing this instruction.
 void process(XPathContext context)
          Process the instruction, without returning any tail calls
protected  void processChildren(XPathContext context)
          Process the children of this instruction, including any tail calls
protected  TailCall processChildrenLeavingTail(XPathContext context)
          Process the children of this node in the stylesheet, returning any tail call made by the last child instruction
abstract  TailCall processLeavingTail(XPathContext context)
          ProcessLeavingTail: called to do the real work of this instruction.
protected  void recoverableError(java.lang.String message, Controller controller)
          Signal a recoverable error.
 void setChildren(Instruction[] children)
          Set the children of this instruction
abstract  void setInstructionDetails(Controller controller, NamePool namePool, InstructionDetails details)
          Get the name of the instruction for use in diagnostics
 void setSourceLocation(int module, int lineNumber)
          Set the system ID and the line number of this instruction.
protected  javax.xml.transform.TransformerException styleError(java.lang.String message, Controller controller)
          Raise a dynamic error
protected  javax.xml.transform.TransformerException styleError(javax.xml.transform.TransformerException error, Controller controller)
          Construct an exception with diagnostic information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

children

protected Instruction[] children
Constructor Detail

Instruction

public Instruction()
Constructor

Method Detail

setChildren

public void setChildren(Instruction[] children)
Set the children of this instruction

Parameters:
children - The instructions that are children of this instruction

getChildren

public Instruction[] getChildren()
Get the children of this instruction

Returns:
the children of this instruction, as an array of Instruction objects

setSourceLocation

public void setSourceLocation(int module,
                              int lineNumber)
Set the system ID and the line number of this instruction.

Parameters:
module - integer identifying the module in which this instruction occurs, This is an index into the module array owned by the Executable object
lineNumber - the line number of this instruction within its module

getSystemId

public java.lang.String getSystemId(Executable exec)
Get the system ID of the source stylesheet module containing this instruction.

Parameters:
exec - The Executable object that owns the index of modules
Returns:
the URI of the containing module

getSystemId

public java.lang.String getSystemId()
Specified by:
getSystemId in interface javax.xml.transform.SourceLocator

getPublicId

public java.lang.String getPublicId()
Specified by:
getPublicId in interface javax.xml.transform.SourceLocator

getColumnNumber

public int getColumnNumber()
Specified by:
getColumnNumber in interface javax.xml.transform.SourceLocator

getLineNumber

public int getLineNumber()
Get the line number of the source stylesheet instruction within its module.

Specified by:
getLineNumber in interface javax.xml.transform.SourceLocator
Returns:
the line number of the instruction

getInstructionDetails

public InstructionDetails getInstructionDetails(Controller controller)
Contruct details of an InstructionInfo for use by the TraceListener.

Parameters:
controller - the Controller for the transformation. This is supplied because (to save space) the Executable is not reachable from an individual Instruction
Returns:
an object containing information about the instruction, designed for use by a TraceListener

setInstructionDetails

public abstract void setInstructionDetails(Controller controller,
                                           NamePool namePool,
                                           InstructionDetails details)
Get the name of the instruction for use in diagnostics


getInstructionName

public java.lang.String getInstructionName()

getResultType

public SequenceType getResultType()
Get the static type of the value returned by the instruction

Returns:
the SequenceType that the returned value will conform to.

processLeavingTail

public abstract TailCall processLeavingTail(XPathContext context)
                                     throws javax.xml.transform.TransformerException
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.

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.
Throws:
javax.xml.transform.TransformerException

process

public void process(XPathContext context)
             throws javax.xml.transform.TransformerException
Process the instruction, without returning any tail calls

Parameters:
context - The dynamic context, giving access to the current node, the current variables, etc.
Throws:
javax.xml.transform.TransformerException

processChildren

protected void processChildren(XPathContext context)
                        throws javax.xml.transform.TransformerException
Process the children of this instruction, including any tail calls

Parameters:
context - The dynamic context for the transformation
Throws:
javax.xml.transform.TransformerException - if a dynamic error occurs

processChildrenLeavingTail

protected TailCall processChildrenLeavingTail(XPathContext context)
                                       throws javax.xml.transform.TransformerException
Process the children of this node in the stylesheet, returning any tail call made by the last child 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.
Throws:
javax.xml.transform.TransformerException

styleError

protected javax.xml.transform.TransformerException styleError(javax.xml.transform.TransformerException error,
                                                              Controller controller)
Construct an exception with diagnostic information. Note that this method returns the exception, it does not throw it: that is up to the caller.

Parameters:
error - The exception containing information about the error
controller - The controller of the transformation
Returns:
an exception based on the supplied exception, but with location information added relating to this instruction

styleError

protected javax.xml.transform.TransformerException styleError(java.lang.String message,
                                                              Controller controller)
Raise a dynamic error

Parameters:
message - An English text error message
controller - The controller of the transformation
Returns:
an exception containing details of the dynamic error

recoverableError

protected void recoverableError(java.lang.String message,
                                Controller controller)
                         throws javax.xml.transform.TransformerException
Signal a recoverable error. The error may be reported if the error handling policy indicates that recoverable errors should be reported

Parameters:
message - an English-language error message
controller - the controller for the transformation
Throws:
javax.xml.transform.TransformerException - - the method throws an exception if the selected policy is not to recover from recoverable errors

assembleParams

protected ParameterSet assembleParams(XPathContext context,
                                      WithParam[] actualParams)
                               throws javax.xml.transform.TransformerException
Assemble a ParameterSet. Method used by instructions that have xsl:with-param children. This method is used for the non-tunnel parameters.

Throws:
javax.xml.transform.TransformerException

assembleTunnelParams

protected ParameterSet assembleTunnelParams(XPathContext context,
                                            WithParam[] actualParams)
                                     throws javax.xml.transform.TransformerException
Assemble a ParameterSet. Method used by instructions that have xsl:with-param children. This method is used for the tunnel parameters.

Throws:
javax.xml.transform.TransformerException