net.sf.saxon.instruct
Class Instruction

java.lang.Object
  |
  +--net.sf.saxon.instruct.Instruction
All Implemented Interfaces:
Instr, Locatable, java.io.Serializable, javax.xml.transform.SourceLocator
Direct Known Subclasses:
AnalyzeString, ApplyImports, ApplyTemplates, Block, CallTemplate, Choose, DeferredError, Doctype, ExprInstruction, ForEach, ForEachGroup, GeneralVariable, Message, NextMatch, NumberInstruction, ResultDocument, While

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

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

See Also:
Serialized Form

Field Summary
protected  Instr[] children
           
 
Constructor Summary
Instruction()
          Constructor
 
Method Summary
protected static ParameterSet assembleParams(XPathContext context, WithParam[] actualParams)
          Assemble a ParameterSet.
protected static ParameterSet assembleTunnelParams(XPathContext context, WithParam[] actualParams)
          Assemble a ParameterSet.
static void displayChildren(Instr[] children, int level, NamePool pool)
          Display the children of an intstruction for diagostics
protected static javax.xml.transform.TransformerException dynamicError(Instr instr, javax.xml.transform.TransformerException error, Controller controller)
          Construct an exception with diagnostic information.
protected  javax.xml.transform.TransformerException dynamicError(java.lang.String message, Controller controller)
          Raise a dynamic error
 int getCardinality()
          Get the cardinality of the sequence returned by evaluating this instruction
 Instr[] getChildren()
          Get the children of this instruction
 int getColumnNumber()
           
 Executable getExecutable()
           
abstract  java.lang.String getInstructionName()
          Get the name of the instruction for use in diagnostics
 java.lang.String getInstructionNamespace()
          Get the namespace of the instruction name.
 ItemType getItemType()
          Get the item type of the items returned by evaluating this instruction
 int getLineNumber()
          Get the line number of the source stylesheet instruction within its module.
 java.lang.String getPublicId()
           
 javax.xml.transform.SourceLocator getSourceLocator()
          Get a SourceLocator identifying the location of this instruction
 java.lang.String getSystemId()
           
 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 instruction, 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 static void recoverableError(Instr instr, java.lang.String message, Controller controller)
          Signal a recoverable error.
 void setChildren(Instr[] children)
          Set the children of this instruction
 void setExecutable(Executable exec)
          Set the containing executable
 void setSourceLocation(int module, int lineNumber)
          Set the system ID and the line number of this instruction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

children

protected Instr[] children
Constructor Detail

Instruction

public Instruction()
Constructor

Method Detail

setExecutable

public void setExecutable(Executable exec)
Set the containing executable


getExecutable

public Executable getExecutable()

setChildren

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

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

getChildren

public Instr[] 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

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()
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

getInstructionName

public abstract java.lang.String getInstructionName()
Get the name of the instruction for use in diagnostics


getInstructionNamespace

public java.lang.String getInstructionNamespace()
Get the namespace of the instruction name. Defaults to the XSLT namespace

Returns:
the namespace of the instruction name

getItemType

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

Returns:
the static item type of the instruction

getCardinality

public int getCardinality()
Get the cardinality of the sequence returned by evaluating this instruction

Returns:
the static cardinality

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.

Specified by:
processLeavingTail in interface Instr
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.
javax.xml.transform.TransformerException

process

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

Specified by:
process in interface Instr
Parameters:
context - The dynamic context, giving access to the current node, the current variables, etc.
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 instruction, 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.
javax.xml.transform.TransformerException

getSourceLocator

public javax.xml.transform.SourceLocator getSourceLocator()
Get a SourceLocator identifying the location of this instruction

Specified by:
getSourceLocator in interface Locatable

dynamicError

protected static javax.xml.transform.TransformerException dynamicError(Instr instr,
                                                                       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

dynamicError

protected javax.xml.transform.TransformerException dynamicError(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 static void recoverableError(Instr instr,
                                       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

displayChildren

public static void displayChildren(Instr[] children,
                                   int level,
                                   NamePool pool)
Display the children of an intstruction for diagostics


assembleParams

protected static 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.

javax.xml.transform.TransformerException

assembleTunnelParams

protected static 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.

javax.xml.transform.TransformerException