org.apache.xalan.templates
Class ElemVariable

java.lang.Object
  extended byorg.apache.xml.utils.UnImplNode
      extended byorg.apache.xalan.templates.ElemTemplateElement
          extended byorg.apache.xalan.templates.ElemVariable
All Implemented Interfaces:
org.w3c.dom.Document, org.w3c.dom.Element, ExpressionNode, org.w3c.dom.Node, org.w3c.dom.NodeList, PrefixResolver, Serializable, javax.xml.transform.SourceLocator, WhitespaceStrippingElementMatcher, XSLTVisitable
Direct Known Subclasses:
ElemExsltFuncResult, ElemParam, ElemVariablePsuedo

public class ElemVariable
extends ElemTemplateElement

Implement xsl:variable.

 
 
 

See Also:
variables in XSLT Specification, Serialized Form

Field Summary
(package private)  int m_frameSize
          The stack frame size for this variable if it is a global variable that declares an RTF, which is equal to the maximum number of variables that can be declared in the variable at one time.
protected  int m_index
          This is the index into the stack frame.
private  boolean m_isTopLevel
          Tells if this is a top-level variable or param, or not.
protected  QName m_qname
          The value of the "name" attribute.
private  XPath m_selectPattern
          The value of the "select" attribute.
 
Fields inherited from class org.apache.xalan.templates.ElemTemplateElement
m_docOrderNumber, m_firstChild, m_hasVariableDecl, m_nextSibling, m_parentNode, m_prefixTable
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
ElemVariable()
          Constructor ElemVariable
ElemVariable(ElemVariable param)
          Copy constructor.
 
Method Summary
protected  boolean accept(XSLTVisitor visitor)
          Accept a visitor and call the appropriate method for this class.
protected  void callChildVisitors(XSLTVisitor visitor, boolean callAttrs)
          Call the children visitors.
 void compose(StylesheetRoot sroot)
          This function is called after everything else has been recomposed, and allows the template to set remaining values that may be based on some other property that depends on recomposition.
 void endCompose(StylesheetRoot sroot)
          This after the template's children have been composed.
 void execute(TransformerImpl transformer)
          Execute a variable declaration and push it onto the variable stack.
 int getIndex()
          If this element is not at the top-level, get the relative position of the variable into the stack frame.
 boolean getIsTopLevel()
          Get if this is a top-level variable or param, or not.
 QName getName()
          Get the "name" attribute.
 String getNodeName()
          Return the node name.
 XPath getSelect()
          Get the "select" attribute.
 XObject getValue(TransformerImpl transformer, int sourceNode)
          Get the XObject representation of the variable.
 int getXSLToken()
          Get an integer representation of the element type.
 boolean isPsuedoVar()
          Tell if this is a psuedo variable reference, declared by Xalan instead of by the user.
 void recompose(StylesheetRoot root)
          This function is called during recomposition to control how this element is composed.
(package private) static XPath rewriteChildToExpression(ElemTemplateElement varElem)
          If the children of a variable is a single xsl:value-of or text literal, it is cheaper to evaluate this as an expression, so try and adapt the child an an expression.
 void setIndex(int index)
          Sets the relative position of this variable within the stack frame (if local) or the global area (if global).
 void setIsTopLevel(boolean v)
          Set if this is a top-level variable or param, or not.
 void setName(QName v)
          Set the "name" attribute.
 void setParentElem(ElemTemplateElement p)
          Set the parent as an ElemTemplateElement.
 void setSelect(XPath v)
          Set the "select" attribute.
 
Methods inherited from class org.apache.xalan.templates.ElemTemplateElement
addOrReplaceDecls, appendChild, appendChild, callChildVisitors, callVisitors, canAcceptVariables, canStripWhiteSpace, compareTo, containsExcludeResultPrefix, error, error, executeNSDecls, executeNSDecls, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, getBaseIdentifier, getChildNodes, getColumnNumber, getDeclaredPrefixes, getDOMBackPointer, getFirstChild, getFirstChildElem, getLastChild, getLastChildElem, getLength, getLineNumber, getLocalName, getNamespaceForPrefix, getNamespaceForPrefix, getNextSibling, getNextSiblingElem, getNodeType, getOwnerDocument, getOwnerXSLTemplate, getParentElem, getParentNode, getParentNodeElem, getPrefixes, getPreviousSibling, getPreviousSiblingElem, getPublicId, getStylesheet, getStylesheetComposed, getStylesheetRoot, getSystemId, getTagName, getUid, getXmlSpace, handlesNullPrefixes, hasChildNodes, hasTextLitOnly, hasVariableDecl, insertBefore, isCompiledTemplate, isValidNCName, item, needToCheckExclude, removeChild, replaceChild, replaceChild, resolvePrefixTables, runtimeInit, setDOMBackPointer, setLocaterInfo, setPrefixes, setPrefixes, setUid, setXmlSpace, shouldStripWhiteSpace, unexecuteNSDecls, unexecuteNSDecls
 
Methods inherited from class org.apache.xml.utils.UnImplNode
adoptNode, appendData, cloneNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getEncoding, getImplementation, getNamespaceURI, getNodeValue, getOwnerElement, getPrefix, getSpecified, getStandalone, getStrictErrorChecking, getVersion, hasAttribute, hasAttributeNS, hasAttributes, importNode, insertData, isSupported, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceData, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setEncoding, setNodeValue, setPrefix, setStandalone, setStrictErrorChecking, setValue, setVersion, splitText, substringData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_index

protected int m_index
This is the index into the stack frame.


m_frameSize

int m_frameSize
The stack frame size for this variable if it is a global variable that declares an RTF, which is equal to the maximum number of variables that can be declared in the variable at one time.


m_selectPattern

private XPath m_selectPattern
The value of the "select" attribute.


m_qname

protected QName m_qname
The value of the "name" attribute.


m_isTopLevel

private boolean m_isTopLevel
Tells if this is a top-level variable or param, or not.

Constructor Detail

ElemVariable

public ElemVariable()
Constructor ElemVariable


ElemVariable

public ElemVariable(ElemVariable param)
             throws javax.xml.transform.TransformerException
Copy constructor.

Parameters:
param - An element created from an xsl:variable
Throws:
javax.xml.transform.TransformerException
Method Detail

setIndex

public void setIndex(int index)
Sets the relative position of this variable within the stack frame (if local) or the global area (if global). Note that this should be called only for global variables since the local position is computed in the compose() method.


getIndex

public int getIndex()
If this element is not at the top-level, get the relative position of the variable into the stack frame. If this variable is at the top-level, get the relative position within the global area.


setSelect

public void setSelect(XPath v)
Set the "select" attribute. If the variable-binding element has a select attribute, then the value of the attribute must be an expression and the value of the variable is the object that results from evaluating the expression. In this case, the content of the variable must be empty.

Parameters:
v - Value to set for the "select" attribute.

getSelect

public XPath getSelect()
Get the "select" attribute. If the variable-binding element has a select attribute, then the value of the attribute must be an expression and the value of the variable is the object that results from evaluating the expression. In this case, the content of the variable must be empty.

Returns:
Value of the "select" attribute.

setName

public void setName(QName v)
Set the "name" attribute. Both xsl:variable and xsl:param have a required name attribute, which specifies the name of the variable. The value of the name attribute is a QName, which is expanded as described in [2.4 Qualified Names].

Parameters:
v - Value to set for the "name" attribute.
See Also:
qname in XSLT Specification

getName

public QName getName()
Get the "name" attribute. Both xsl:variable and xsl:param have a required name attribute, which specifies the name of the variable. The value of the name attribute is a QName, which is expanded as described in [2.4 Qualified Names].

Returns:
Value of the "name" attribute.
See Also:
qname in XSLT Specification

setIsTopLevel

public void setIsTopLevel(boolean v)
Set if this is a top-level variable or param, or not.

Parameters:
v - Boolean indicating whether this is a top-level variable or param, or not.
See Also:
top-level-variables in XSLT Specification

getIsTopLevel

public boolean getIsTopLevel()
Get if this is a top-level variable or param, or not.

Returns:
Boolean indicating whether this is a top-level variable or param, or not.
See Also:
top-level-variables in XSLT Specification

getXSLToken

public int getXSLToken()
Get an integer representation of the element type.

Overrides:
getXSLToken in class ElemTemplateElement
Returns:
An integer representation of the element, defined in the Constants class.
See Also:
Constants

getNodeName

public String getNodeName()
Return the node name.

Specified by:
getNodeName in interface org.w3c.dom.Node
Overrides:
getNodeName in class ElemTemplateElement
Returns:
The node name

execute

public void execute(TransformerImpl transformer)
             throws javax.xml.transform.TransformerException
Execute a variable declaration and push it onto the variable stack.

Overrides:
execute in class ElemTemplateElement
Parameters:
transformer - non-null reference to the the current transform-time state.
Throws:
javax.xml.transform.TransformerException
See Also:
variables in XSLT Specification

getValue

public XObject getValue(TransformerImpl transformer,
                        int sourceNode)
                 throws javax.xml.transform.TransformerException
Get the XObject representation of the variable.

Parameters:
transformer - non-null reference to the the current transform-time state.
sourceNode - non-null reference to the current source node.
Returns:
the XObject representation of the variable.
Throws:
javax.xml.transform.TransformerException

compose

public void compose(StylesheetRoot sroot)
             throws javax.xml.transform.TransformerException
This function is called after everything else has been recomposed, and allows the template to set remaining values that may be based on some other property that depends on recomposition.

Overrides:
compose in class ElemTemplateElement
Throws:
javax.xml.transform.TransformerException

endCompose

public void endCompose(StylesheetRoot sroot)
                throws javax.xml.transform.TransformerException
This after the template's children have been composed. We have to get the count of how many variables have been declared, so we can do a link and unlink.

Overrides:
endCompose in class ElemTemplateElement
Throws:
javax.xml.transform.TransformerException

rewriteChildToExpression

static XPath rewriteChildToExpression(ElemTemplateElement varElem)
                               throws javax.xml.transform.TransformerException
If the children of a variable is a single xsl:value-of or text literal, it is cheaper to evaluate this as an expression, so try and adapt the child an an expression.

Parameters:
varElem - Should be a ElemParam, ElemVariable, or ElemWithParam.
Returns:
An XPath if rewrite is possible, else null.
Throws:
javax.xml.transform.TransformerException

recompose

public void recompose(StylesheetRoot root)
This function is called during recomposition to control how this element is composed.

Overrides:
recompose in class ElemTemplateElement
Parameters:
root - The root stylesheet for this transformation.

setParentElem

public void setParentElem(ElemTemplateElement p)
Set the parent as an ElemTemplateElement.

Overrides:
setParentElem in class ElemTemplateElement

accept

protected boolean accept(XSLTVisitor visitor)
Accept a visitor and call the appropriate method for this class.

Overrides:
accept in class ElemTemplateElement
Parameters:
visitor - The visitor whose appropriate method will be called.
Returns:
true if the children of the object should be visited.

callChildVisitors

protected void callChildVisitors(XSLTVisitor visitor,
                                 boolean callAttrs)
Call the children visitors.

Overrides:
callChildVisitors in class ElemTemplateElement
Parameters:
visitor - The visitor whose appropriate method will be called.

isPsuedoVar

public boolean isPsuedoVar()
Tell if this is a psuedo variable reference, declared by Xalan instead of by the user.