com.novell.xsl.process
Class ProcessingEnv

java.lang.Object
  extended bycom.novell.xsl.process.ProcessingEnv

public class ProcessingEnv
extends Object

Processing environment containing information needed to process source nodes. Also includes various utility methods.


Constructor Summary
ProcessingEnv(ProcessingEnv iVal)
          Construct a new processing environment that is a deep copy of the passed instance.
ProcessingEnv(Stylesheet stylesheet, Context context, Document nodeFactory, ErrorHandler errorHandler, MessageHandler messageHandler, ResultHandler topLevelResultHandler)
          Constructs a new processing environment for the specified Stylesheet.
 
Method Summary
 void bindParameter(ExpandedQName name, ExpressionValue value)
          Bind an expression value to a parameter name
static StringBuffer buildMsgPrologue(StringBuffer prologue, Node contextNode)
          Construct a message prologue with context information (contextNode) source document URI and line number, if contextNode is an instance of com.novell.xml.dom.NodeImpl
 void clearParameters()
          Clear any parameters that may be bound.
 Context getContext()
          Return the expression context from this environment.
 Rule getCurrentRule()
          Returns the current template rule (the current template rule chosen by matching a pattern).
 ErrorHandler getErrorHandler()
          Returns the error handler to which processing errors and warnings should be reported.
 MessageHandler getMessageHandler()
          Returns the message handler to which xsl:message content should be reported.
 Document getNodeFactory()
          Get the Node factory object
 ExpressionValue getParameter(ExpandedQName name)
          Get a bound parameter by name
 Stylesheet getStylesheet()
          Return the stylesheet associated with this processing environment.
 ResultHandler getTopLevelResultHandler()
          Return the result handler in effect for the top-level processing of the stylesheet.
 Rule popCurrentRule()
          Remove the current template rule and restore the previous current template rule.
 void popParameters()
          Pop previously bound template parameters after instantiation of a template.
 void popVariables()
          Restore variable state after recursion.
 void process(Node source, Mode mode, ResultHandler result)
          Uses this processing environment to process the specified source node in the specified mode, sending the result to the specified result handler.
 void processWithImports(Node source, ResultHandler result)
          Process the current node with imported rules only (xsl:apply-imports functionality)
 void processWithRule(Node source, Mode mode, ResultHandler result, Rule rule)
          Uses this processing environment to process the specified source node in the specified mode, sending the result to the specified result handler, given a Rule.
 void pushCurrentRule(Rule rule)
          Set a template rule as the current template rule
 void pushParameters()
          Push currently bound template parameters and clear in preparation for instantiating a template.
 void pushVariables()
          Save current set of local variables and their values.
 void reportError(Node contextNode, String key)
          Report an error to the ErrorHandler with source stylesheet context.
 void reportError(Node contextNode, String key, Object[] parms)
          Report an error to the ErrorHandler with source stylesheet context.
 void reportError(Node contextNode, String key, String parm0)
          Report an error to the ErrorHandler with source stylesheet context.
 void reportError(Node contextNode, String key, String parm0, String parm1)
          Report an error to the ErrorHandler with source stylesheet context.
 void reportError(String msg)
          Report an error to the ErrorHandler, convert any thrown XSLException to a ProcessException
 void reportWarning(Node contextNode, String key, Object[] parms)
          Report a warning to the ErrorHandler with source stylesheet context.
static void resultNamespace(ResultHandler result, String prefix, NamespaceName nsName)
          Utility method for sending namespace nodes to result handler.
 void setNodeFactory(Document nodeFactory)
          Set the Node factory object
 void setVariable(VariableTemplate variable)
          Remember a variable and its current value in the current execution (run time) scope.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessingEnv

public ProcessingEnv(Stylesheet stylesheet,
                     Context context,
                     Document nodeFactory,
                     ErrorHandler errorHandler,
                     MessageHandler messageHandler,
                     ResultHandler topLevelResultHandler)
Constructs a new processing environment for the specified Stylesheet.

Parameters:
stylesheet - the Stylesheet doing the processing
context - The XPath expression context for this environment.
errorHandler - the error handler to report processing errors and warnings to
messageHandler - the message handler to report xsl:message messages
topLevelResultHandler - the result handler for the top level of processing

ProcessingEnv

public ProcessingEnv(ProcessingEnv iVal)
Construct a new processing environment that is a deep copy of the passed instance.

Parameters:
iVal - The ProcessingEnv to copy.
Method Detail

getErrorHandler

public ErrorHandler getErrorHandler()
Returns the error handler to which processing errors and warnings should be reported.

Returns:
the error handler to report processing errors and warnings to

getMessageHandler

public MessageHandler getMessageHandler()
Returns the message handler to which xsl:message content should be reported.

Returns:
the message handler

getContext

public Context getContext()
Return the expression context from this environment.

Returns:
The XPath ExpressionContext object.

process

public void process(Node source,
                    Mode mode,
                    ResultHandler result)
             throws XSLException
Uses this processing environment to process the specified source node in the specified mode, sending the result to the specified result handler.

Parameters:
source - the source node to be processed
mode - the mode to process in
result - the handler to which results are sent
Throws:
XSLException - if a fatal error occurs during processing

processWithImports

public void processWithImports(Node source,
                               ResultHandler result)
                        throws XSLException
Process the current node with imported rules only (xsl:apply-imports functionality)

Parameters:
source - The source node to be processed
result - The handler to which results are sent
Throws:
XSLException - if a fatal error occurs during processing

processWithRule

public void processWithRule(Node source,
                            Mode mode,
                            ResultHandler result,
                            Rule rule)
                     throws XSLException
Uses this processing environment to process the specified source node in the specified mode, sending the result to the specified result handler, given a Rule.

Parameters:
source - the source node to be processed
mode - the mode to process in
result - the handler to which results are sent
rule - the Rule to instantiate for the node
Throws:
XSLException - if a fatal error occurs during processing

getStylesheet

public Stylesheet getStylesheet()
Return the stylesheet associated with this processing environment.

Returns:
The stylesheet.

bindParameter

public void bindParameter(ExpandedQName name,
                          ExpressionValue value)
Bind an expression value to a parameter name

Parameters:
name - The name of the parameter to bind
value - The expression value to bind

getParameter

public ExpressionValue getParameter(ExpandedQName name)
Get a bound parameter by name

Parameters:
name - The name of the parameter to retrieve
Returns:
The expression value of the named parameters, or null if no parameter is bound to the passed name.

clearParameters

public void clearParameters()
Clear any parameters that may be bound.


pushParameters

public void pushParameters()
Push currently bound template parameters and clear in preparation for instantiating a template.


popParameters

public void popParameters()
Pop previously bound template parameters after instantiation of a template.


setVariable

public void setVariable(VariableTemplate variable)
Remember a variable and its current value in the current execution (run time) scope.

Parameters:
variable - The local variable to remember

pushVariables

public void pushVariables()
Save current set of local variables and their values. Designed to be called for recursion, e.g., xsl:apply-templates and xsl:call-template. Reset current variable list to nothing.


popVariables

public void popVariables()
Restore variable state after recursion. Undoes pushVariables()


getTopLevelResultHandler

public ResultHandler getTopLevelResultHandler()
Return the result handler in effect for the top-level processing of the stylesheet.

Returns:
The result handler

getCurrentRule

public Rule getCurrentRule()
Returns the current template rule (the current template rule chosen by matching a pattern).

Returns:
The current template rule, or null if there is no current rule (xsl:for-each sets the current rule to null)

pushCurrentRule

public void pushCurrentRule(Rule rule)
Set a template rule as the current template rule

Parameters:
rule - The template rule to set as the current template rule.

popCurrentRule

public Rule popCurrentRule()
Remove the current template rule and restore the previous current template rule.

Returns:
The popped rule.

getNodeFactory

public Document getNodeFactory()
Get the Node factory object

Returns:
The Document object being used as the node factory

setNodeFactory

public void setNodeFactory(Document nodeFactory)
Set the Node factory object

Parameters:
nodeFactory - The Document object to use as the node factory

resultNamespace

public static void resultNamespace(ResultHandler result,
                                   String prefix,
                                   NamespaceName nsName)
                            throws ResultException
Utility method for sending namespace nodes to result handler. This filters definitions for the xml namespace used for xml:space and xml:lang.

Parameters:
result - The ResultHandler to which to send the namespace node.
prefix - The prefix associated with the namespace node
nsName - The namespace name (URI) associated with the namespace node
Throws:
ResultException

reportError

public void reportError(String msg)
                 throws XSLException
Report an error to the ErrorHandler, convert any thrown XSLException to a ProcessException

Parameters:
msg - The message text
Throws:
XSLException - if the ErrorHandler throws an error when ErrorHandler.error() is called.

reportError

public void reportError(Node contextNode,
                        String key)
                 throws XSLException
Report an error to the ErrorHandler with source stylesheet context.

Parameters:
key - The key for the message format string in the properties file.
Throws:
XSLException - if the ErrorHandler throws an error when ErrorHandler.error() is called.

reportError

public void reportError(Node contextNode,
                        String key,
                        String parm0)
                 throws XSLException
Report an error to the ErrorHandler with source stylesheet context.

Parameters:
key - The key for the message format string in the properties file.
parm0 - The parameter for the message format string
Throws:
XSLException - if the ErrorHandler throws an error when ErrorHandler.error() is called.

reportError

public void reportError(Node contextNode,
                        String key,
                        String parm0,
                        String parm1)
                 throws XSLException
Report an error to the ErrorHandler with source stylesheet context.

Parameters:
key - The key for the message format string in the properties file.
parm0 - The first parameter for the message format string
parm1 - The second parameter for the message format string
Throws:
XSLException - if the ErrorHandler throws an error when ErrorHandler.error() is called.

reportError

public void reportError(Node contextNode,
                        String key,
                        Object[] parms)
                 throws XSLException
Report an error to the ErrorHandler with source stylesheet context.

Parameters:
key - The key for the message format string in the properties file.
parms - The parametersfor the message format string
Throws:
XSLException - if the ErrorHandler throws an error when ErrorHandler.error() is called.

reportWarning

public void reportWarning(Node contextNode,
                          String key,
                          Object[] parms)
Report a warning to the ErrorHandler with source stylesheet context.

Parameters:
key - The key for the message format string in the properties file.
parms - The parametersfor the message format string
Throws:
XSLException - if the ErrorHandler throws an error when ErrorHandler.error() is called.

buildMsgPrologue

public static StringBuffer buildMsgPrologue(StringBuffer prologue,
                                            Node contextNode)
Construct a message prologue with context information (contextNode) source document URI and line number, if contextNode is an instance of com.novell.xml.dom.NodeImpl

Parameters:
prologue - The StringBuffer in which to build the prologue. If null, a new StringBuffer is allocated.
contextNode - The node that supplies the message context
Throws:
XSLException - if the ErrorHandler throws an error when ErrorHandler.error() is called.