<xsl:for-each select="c:richBody">
<xsl:if test="position()=1">
<div style="height:50px;" />
</xsl:if>
<xsl:apply-templates />
</xsl:for-each>
I have the code blurb above and need to do something in between the first c:richBody element and the second c:richBody. It looks like when it is getting to applytemplates it just goes through all of them and then goes down the doc. With what I have above the height 50 div gets placed above all the apply-templates.
Is there any way to do something inbetween the items that are 开发者_开发问答getting apply-templates applied to them?
I believe your problem is that you are thinking in "C", where the first item has position()=0; the second has position()=1 ...
However, for XSLT you have to think like a sane person instead. The first item has position() = 1. To insert your div before the second item, your test should be if test="position()=2"
As a guess, I'd say you want
<xsl:if test="position()>1">
which would give you a div between all the c:richBody
tags.
精彩评论