org.apache.xalan.xsltc.dom

Class ForwardPositionIterator

Implemented Interfaces:
Cloneable, DTMAxisIterator

public final class ForwardPositionIterator
extends DTMAxisIteratorBase

This iterator is a wrapper that always returns the position of a node in document order. It is needed for the case where a call to position() occurs in the context of an XSLT element such as xsl:for-each, xsl:apply-templates, etc. The getPosition() methods in DTMAxisIterators defined in DTMDefaultBaseIterators always return the position in document order, which is backwards for XPath in the case of the ancestor, ancestor-or-self, previous and previous-sibling. XSLTC implements position() with the BasisLibrary.positionF() method, and uses the DTMAxisIterator.isReverse() method to determine whether the result of getPosition() should be interpreted as being equal to position(). But when the expression appears in apply-templates of for-each, the position() function operates in document order. The only effect of the ForwardPositionIterator is to force the result of isReverse() to false, so that BasisLibrary.positionF() calculates position() in a way that's consistent with the context in which the iterator is being used." (Apparently the correction of isReverse() occurs implicitly, by inheritance. This class also appears to maintain its own position counter, which seems redundant.)

Fields inherited from interface org.apache.xml.dtm.DTMAxisIterator

END

Constructor Summary

ForwardPositionIterator(DTMAxisIterator source)

Method Summary

DTMAxisIterator
cloneIterator()
void
gotoMark()
int
next()
DTMAxisIterator
reset()
void
setMark()
DTMAxisIterator
setStartNode(int node)

Methods inherited from class org.apache.xml.dtm.ref.DTMAxisIteratorBase

cloneIterator, getAxis, getLast, getNodeByPosition, getPosition, getStartNode, includeSelf, isDocOrdered, isReverse, reset, setRestartable

Constructor Details

ForwardPositionIterator

public ForwardPositionIterator(DTMAxisIterator source)

Method Details

cloneIterator

public DTMAxisIterator cloneIterator()
Specified by:
cloneIterator in interface DTMAxisIterator
Overrides:
cloneIterator in interface DTMAxisIteratorBase

gotoMark

public void gotoMark()
Specified by:
gotoMark in interface DTMAxisIterator

next

public int next()
Specified by:
next in interface DTMAxisIterator

reset

public DTMAxisIterator reset()
Specified by:
reset in interface DTMAxisIterator
Overrides:
reset in interface DTMAxisIteratorBase

setMark

public void setMark()
Specified by:
setMark in interface DTMAxisIterator

setStartNode

public DTMAxisIterator setStartNode(int node)
Specified by:
setStartNode in interface DTMAxisIterator

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