如果我有每个循环,例如:
<xsl:for-each select="$pChildren">
<xsl:variable name="vNext" select="???" />
</xsl:for-each>
我正在尝试将for-each循环中要迭代的下一个节点分配给vNext
,如果有的话。
我尝试$pChildren[position()+1]
但没有效果。
答案 0 :(得分:3)
我希望在看到整个背景时回答这个问题,但我相信:
<xsl:for-each select="$pChildren">
<xsl:variable name="i" select="position()" />
<xsl:variable name="vNext" select="$pChildren[$i + 1]" />
</xsl:for-each>
应该适合你。
答案 1 :(得分:0)
如果要引用序列中的下一个项目,则可能不应该首先使用xsl:for-each语句。颠倒节点的顺序并使用xsl:iterate(除非你主要使用多线程)。
更自然的方法是:
<xsl:iterate select="reverse($pchildren)">
<xsl:param name="last" select="()"/>
Do Stuff Here using $last to reference the item that comes next in $pchildren.
<xsl:next-iteration>
<xsl:with-param name="last" select="."/>
</xsl:next-iteration>
</xsl:iterate/>