org.apache.xalan.templates

Class ElemForEach

Implemented Interfaces:
Document, Element, ExpressionNode, ExpressionOwner, Node, NodeList, PrefixResolver, Serializable, SourceLocator, WhitespaceStrippingElementMatcher, XSLTVisitable
Known Direct Subclasses:
ElemCallTemplate

public class ElemForEach
extends ElemTemplateElement
implements ExpressionOwner

Implement xsl:for-each.
 <!ELEMENT xsl:for-each
  (#PCDATA
   %instructions;
   %result-elements;
   | xsl:sort)
 >

 <!ATTLIST xsl:for-each
   select %expr; #REQUIRED
   %space-att;
 >
 
See Also:
for-each in XSLT Specification

Field Summary

boolean
m_doc_cache_off
This is set by an "xalan-doc-cache-off" pi, or the old "xalan:doc-cache-off" pi.

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()
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.
int
getXSLToken()
Get an int constant identifying the type of element.
void
setExpression(Expression exp)
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

appendChild, appendChild, callVisitors, canAcceptVariables, canStripWhiteSpace, compareTo, compose, containsExcludeResultPrefix, endCompose, error, error, execute, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, getBaseIdentifier, getChildNodes, getColumnNumber, getDOMBackPointer, getDeclaredPrefixes, getEndColumnNumber, getEndLineNumber, getFirstChild, getFirstChildElem, getLastChild, getLastChildElem, getLength, getLineNumber, getLocalName, getNamespaceForPrefix, getNamespaceForPrefix, getNextSibling, getNextSiblingElem, getNodeName, getNodeType, getOwnerDocument, getOwnerXSLTemplate, getParentElem, getParentNode, getParentNodeElem, getPrefixes, getPreviousSibling, getPreviousSiblingElem, getPublicId, getStylesheet, getStylesheetComposed, getStylesheetRoot, getSystemId, getTagName, getUid, getXSLToken, getXmlSpace, handlesNullPrefixes, hasChildNodes, hasTextLitOnly, hasVariableDecl, insertBefore, isCompiledTemplate, item, recompose, removeChild, replaceChild, replaceChild, resolvePrefixTables, runtimeInit, setDOMBackPointer, setEndLocaterInfo, setLocaterInfo, setParentElem, setPrefixes, setPrefixes, setUid, setXmlSpace, shouldStripWhiteSpace

Methods inherited from class org.apache.xml.utils.UnImplNode

adoptNode, appendChild, appendData, cloneNode, compareDocumentPosition, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, error, error, getActualEncoding, getAttribute, getAttributeNS, getAttributeNode, getAttributeNodeNS, getAttributes, getBaseURI, getChildNodes, getDoctype, getDocumentElement, getDocumentURI, getDomConfig, getElementById, getElementsByTagName, getElementsByTagNameNS, getFeature, getFirstChild, getImplementation, getInputEncoding, getLastChild, getLength, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getOwnerElement, getParentNode, getPrefix, getPreviousSibling, getSchemaTypeInfo, getSpecified, getStrictErrorChecking, getTagName, getTextContent, getUserData, getWholeText, getXmlEncoding, getXmlStandalone, getXmlVersion, hasAttribute, hasAttributeNS, hasAttributes, hasChildNodes, importNode, insertBefore, insertData, isDefaultNamespace, isEqualNode, isId, isSameNode, isSupported, isWhitespaceInElementContent, item, lookupNamespaceURI, lookupPrefix, normalize, normalizeDocument, removeAttribute, removeAttributeNS, removeAttributeNode, removeChild, renameNode, replaceChild, replaceData, replaceWholeText, setActualEncoding, setAttribute, setAttributeNS, setAttributeNode, setAttributeNodeNS, setData, setDocumentURI, setIdAttribute, setIdAttribute, setIdAttributeNS, setIdAttributeNode, setInputEncoding, setNodeValue, setPrefix, setStrictErrorChecking, setTextContent, setUserData, setValue, setXmlEncoding, setXmlStandalone, setXmlVersion, splitText, substringData

Field Details

m_doc_cache_off

public boolean m_doc_cache_off
This is set by an "xalan-doc-cache-off" pi, or the old "xalan:doc-cache-off" pi. The old form of the PI only works for XML parsers that are not namespace aware. 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.

Constructor Details

ElemForEach

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

Method Details

appendChild

public ElemTemplateElement appendChild(ElemTemplateElement newChild)
Add a child to the child list. <!ELEMENT xsl:apply-templates (xsl:sort|xsl:with-param)*> <!ATTLIST xsl:apply-templates select %expr; "node()" mode %qname; #IMPLIED >
Overrides:
appendChild in interface 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.
Parameters:
visitor - The visitor whose appropriate method will be called.

compose

public void compose(StylesheetRoot sroot)
            throws 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 interface ElemTemplateElement

endCompose

public void endCompose(StylesheetRoot sroot)
            throws TransformerException
This after the template's children have been composed.
Overrides:
endCompose in interface ElemTemplateElement

execute

public void execute(TransformerImpl transformer)
            throws TransformerException
Execute the xsl:for-each transformation
Overrides:
execute in interface ElemTemplateElement
Parameters:
transformer - non-null reference to the the current transform-time state.

getExpression

public Expression getExpression()
Specified by:
getExpression in interface ExpressionOwner

getNodeName

public String getNodeName()
Return the node name.
Overrides:
getNodeName in interface ElemTemplateElement
Returns:
The element's name

getSelect

public Expression getSelect()
Get the "select" attribute.
Returns:
The XPath expression for the "select" attribute.

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

getSortElemCount

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

getXSLToken

public int getXSLToken()
Get an int constant identifying the type of element.
Overrides:
getXSLToken in interface ElemTemplateElement
Returns:
The token ID for this element
See Also:
Constants

setExpression

public void setExpression(Expression exp)
Specified by:
setExpression in interface ExpressionOwner

setSelect

public void setSelect(XPath xpath)
Set the "select" attribute.
Parameters:
xpath - The XPath expression for the "select" attribute.

setSortElem

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

sortNodes

public DTMIterator sortNodes(XPathContext xctxt,
                             Vector keys,
                             DTMIterator sourceNodes)
            throws 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

transformSelectedNodes

public void transformSelectedNodes(TransformerImpl transformer)
            throws TransformerException
Perform a query if needed, and call transformNode for each child.
Parameters:
transformer - non-null reference to the the current transform-time state.

Copyright B) 2005 Apache XML Project. All Rights Reserved.