org.apache.xalan.templates
Class ElemForEach

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

public class ElemForEach
extends ElemTemplateElement
implements ExpressionOwner

Implement xsl:for-each.

 

 
 

See Also:
for-each in XSLT Specification, Serialized Form

Field Summary
(package private) static boolean DEBUG
          Set true to request some basic status reports
 boolean m_doc_cache_off
          This is set by an "xalan:doc-cache-off" pi.
protected  Expression m_selectExpression
          The "select" expression.
protected  Vector m_sortElems
          Vector containing the xsl:sort elements associated with this element.
 
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
ElemForEach()
          Construct a element representing xsl:for-each.
 
Method Summary
 ElemTemplateElement appendChild(ElemTemplateElement newChild)
          Add a child to the child list
 void callChildVisitors(XSLTVisitor visitor, boolean callAttributes)
          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 the xsl:for-each transformation
 Expression getExpression()
          Get the raw Expression object that this class wraps.
 String getNodeName()
          Return the node name.
 Expression getSelect()
          Get the "select" attribute.
 ElemSort getSortElem(int i)
          Get a xsl:sort element associated with this element.
 int getSortElemCount()
          Get the count xsl:sort elements associated with this element.
protected  ElemTemplateElement getTemplateMatch()
          Get template element associated with this
 int getXSLToken()
          Get an int constant identifying the type of element.
 void setExpression(Expression exp)
          Set the raw expression object for this object.
 void setSelect(XPath xpath)
          Set the "select" attribute.
 void setSortElem(ElemSort sortElem)
          Set a xsl:sort element associated with this element.
 DTMIterator sortNodes(XPathContext xctxt, Vector keys, DTMIterator sourceNodes)
          Sort given nodes
 void transformSelectedNodes(TransformerImpl transformer)
           Perform a query if needed, and call transformNode for each child.
 
Methods inherited from class org.apache.xalan.templates.ElemTemplateElement
accept, addOrReplaceDecls, 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, recompose, removeChild, replaceChild, replaceChild, resolvePrefixTables, runtimeInit, setDOMBackPointer, setLocaterInfo, setParentElem, 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

DEBUG

static final boolean DEBUG
Set true to request some basic status reports

See Also:
Constant Field Values

m_doc_cache_off

public boolean m_doc_cache_off
This is set by an "xalan:doc-cache-off" pi. It tells the engine that documents created in the location paths executed by this element will not be reparsed. It's set by StylesheetHandler during construction. Note that this feature applies _only_ to xsl:for-each elements in its current incarnation; a more general cache management solution is desperately needed.


m_selectExpression

protected Expression m_selectExpression
The "select" expression.


m_sortElems

protected Vector m_sortElems
Vector containing the xsl:sort elements associated with this element.

Constructor Detail

ElemForEach

public ElemForEach()
Construct a element representing xsl:for-each.

Method Detail

setSelect

public void setSelect(XPath xpath)
Set the "select" attribute.

Parameters:
xpath - The XPath expression for the "select" attribute.

getSelect

public Expression getSelect()
Get the "select" attribute.

Returns:
The XPath expression for the "select" attribute.

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. NEEDSDOC @param sroot

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.

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

getSortElemCount

public int getSortElemCount()
Get the count xsl:sort elements associated with this element.

Returns:
The number of xsl:sort elements.

getSortElem

public ElemSort getSortElem(int i)
Get a xsl:sort element associated with this element.

Parameters:
i - Index of xsl:sort element to get
Returns:
xsl:sort element at given index

setSortElem

public void setSortElem(ElemSort sortElem)
Set a xsl:sort element associated with this element.

Parameters:
sortElem - xsl:sort element to set

getXSLToken

public int getXSLToken()
Get an int constant identifying the type of element.

Overrides:
getXSLToken in class ElemTemplateElement
Returns:
The token ID for this element
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 element's name

execute

public void execute(TransformerImpl transformer)
             throws javax.xml.transform.TransformerException
Execute the xsl:for-each transformation

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

getTemplateMatch

protected ElemTemplateElement getTemplateMatch()
Get template element associated with this

Returns:
template element associated with this (itself)

sortNodes

public DTMIterator sortNodes(XPathContext xctxt,
                             Vector keys,
                             DTMIterator sourceNodes)
                      throws javax.xml.transform.TransformerException
Sort given nodes

Parameters:
xctxt - The XPath runtime state for the sort.
keys - Vector of sort keyx
sourceNodes - Iterator of nodes to sort
Returns:
iterator of sorted nodes
Throws:
javax.xml.transform.TransformerException

transformSelectedNodes

public void transformSelectedNodes(TransformerImpl transformer)
                            throws javax.xml.transform.TransformerException
Perform a query if needed, and call transformNode for each child.

Parameters:
transformer - non-null reference to the the current transform-time state.
Throws:
javax.xml.transform.TransformerException - Thrown in a variety of circumstances.

appendChild

public ElemTemplateElement appendChild(ElemTemplateElement newChild)
Add a child to the child list.

Overrides:
appendChild in class ElemTemplateElement
Parameters:
newChild - Child to add to child list
Returns:
Child just added to child list

callChildVisitors

public void callChildVisitors(XSLTVisitor visitor,
                              boolean callAttributes)
Call the children visitors.

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

getExpression

public Expression getExpression()
Description copied from interface: ExpressionOwner
Get the raw Expression object that this class wraps.

Specified by:
getExpression in interface ExpressionOwner
Returns:
the raw Expression object, which should not normally be null.
See Also:
ExpressionOwner.getExpression()

setExpression

public void setExpression(Expression exp)
Description copied from interface: ExpressionOwner
Set the raw expression object for this object.

Specified by:
setExpression in interface ExpressionOwner
Parameters:
exp - the raw Expression object, which should not normally be null.
See Also:
ExpressionOwner.setExpression(Expression)