com.novell.xsl.process
Class VariableTemplate

java.lang.Object
  extended bycom.novell.xsl.process.TemplateCollection
      extended bycom.novell.xsl.process.VariableTemplate
All Implemented Interfaces:
Expression, Template
Direct Known Subclasses:
AssignVariableTemplate, TopLevelVariableTemplate, WithParamTemplate

public class VariableTemplate
extends TemplateCollection
implements Expression

A template that instantiates an XSLT variable NOTE: this template implements the functionality of both xsl:variable and xsl:param. The reason for this is so that the top-level xsl:variable and xsl:param can share functionality (top-level vars and params have a little different behavior)

See Also:
TopLevelVariableTemplate

Field Summary
protected  ExpressionValue currentValue
          Current value of the variable during execution of the stylesheet
 
Constructor Summary
VariableTemplate(ExpandedQName name, Expression select, Template[] templates, boolean isParam, Node nsContext)
          Constructs a VariableTemplate that create binds a value to a variable
VariableTemplate(ExpandedQName name, Expression select, Template[] templates, Node nsContext)
          Constructs a VariableTemplate that create binds a value to a variable
 
Method Summary
 void dump(PrintWriter out, int indent)
          Dumps this object to the specified output stream.
 ExpressionValue evaluate(Node contextNode, ExpressionContext context)
          Evaluate the expression with repect to the passed context Note: The contextNode and context parameters may be null if and only if isConstant() returns true for the expression implementation.
 ExpressionValue getCurrentValue()
          Return the current variable value.
 ExpandedQName getName()
          Return the name of this variable.
 Class getResultType()
          Return the Class object describing the result type of the expression.
 Expression getSelect()
          Return the select expression (if any) of this variable.
 void instantiate(ProcessingEnv env, Node currentNode, ResultHandler result)
          Instantiates this template for the specified current node and sends the result to the specified result handler.
 boolean isConstant()
          Return true if the expression is a constant value.
 boolean isParam()
          Return true if this object represents an xsl:param element.
 void registerForReset(XPathResetRegistrar registrar)
          Register this expression or any subexpression that implements XPathResetCache with an object that wants to call resetCache()
 void setCurrentValue(ExpressionValue value)
          Set the current variable value.
 
Methods inherited from class com.novell.xsl.process.TemplateCollection
getNamespaceContext, getTemplates, instantiateTemplates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentValue

protected ExpressionValue currentValue
Current value of the variable during execution of the stylesheet

Constructor Detail

VariableTemplate

public VariableTemplate(ExpandedQName name,
                        Expression select,
                        Template[] templates,
                        Node nsContext)
Constructs a VariableTemplate that create binds a value to a variable

Parameters:
name - the name of the variable (a expanded name)
select - the optional expression that is evaluated to give the the value of the variable
templates - the templates to be evaluated to get the variable's value if no select expression is given
nsContext - The node in the style sheet from which this template comes

VariableTemplate

public VariableTemplate(ExpandedQName name,
                        Expression select,
                        Template[] templates,
                        boolean isParam,
                        Node nsContext)
Constructs a VariableTemplate that create binds a value to a variable

Parameters:
name - the name of the variable (an expanded name)
select - the optional expression that is evaluated to give the the value of the variable
templates - the templates to be evaluated to get the variable's value if no select expression is given
isParam - true if this represents an xsl:param element
nsContext - The node in the style sheet from which this template comes
Method Detail

getName

public ExpandedQName getName()
Return the name of this variable.

Returns:
The expanded QName of this variable.

getSelect

public Expression getSelect()
Return the select expression (if any) of this variable.

Returns:
The select expression or null.

isParam

public boolean isParam()
Return true if this object represents an xsl:param element.

Returns:
True if this object represents an xsl:param element.

getCurrentValue

public ExpressionValue getCurrentValue()
Return the current variable value.

Returns:
The current variable value, or null if not yet evaluated

setCurrentValue

public void setCurrentValue(ExpressionValue value)
Set the current variable value. This is primarily for the use of TemplateRule for saving and restoring variable state during recursion.

Parameters:
value - The variable value to set

instantiate

public void instantiate(ProcessingEnv env,
                        Node currentNode,
                        ResultHandler result)
                 throws XSLException
Instantiates this template for the specified current node and sends the result to the specified result handler.

For a VariableTemplate, this method evaluates the select expression, or instantiates the result fragment template, and places the variable within scope.

Specified by:
instantiate in interface Template
Parameters:
env - the current processing environment
currentNode - the current source node
result - the handler to which results are sent
Throws:
XSLException - if a fatal error occurs during instantiation

dump

public void dump(PrintWriter out,
                 int indent)
Dumps this object to the specified output stream. Note this implements dump() for both Template and Expression

Specified by:
dump in interface Expression
Overrides:
dump in class TemplateCollection
Parameters:
out - the output stream to write to
indent - number of tabs to indent

evaluate

public ExpressionValue evaluate(Node contextNode,
                                ExpressionContext context)
                         throws XPathEvaluationException
Evaluate the expression with repect to the passed context Note: The contextNode and context parameters may be null if and only if isConstant() returns true for the expression implementation.

Specified by:
evaluate in interface Expression
Parameters:
contextNode - context node for expression evaluation
context - expression context for expression evaluation
Returns:
result of evaluating expression
Throws:
XPathEvaluationException

isConstant

public boolean isConstant()
Return true if the expression is a constant value.

Specified by:
isConstant in interface Expression
Returns:
false (this is a variable, after all)

getResultType

public Class getResultType()
Return the Class object describing the result type of the expression.

Specified by:
getResultType in interface Expression
Returns:
A Class object.

registerForReset

public void registerForReset(XPathResetRegistrar registrar)
Register this expression or any subexpression that implements XPathResetCache with an object that wants to call resetCache()

Specified by:
registerForReset in interface Expression