sorry, but i still don't get it, even after consulting the xslt specification. there is some fundametal misunderstanding between me and xslt processing model.
can you please explain, where do i do the mistake in my assumptions? this is the stylesheet from above, this time with line numbers
Code:
1 <xsl:template match="c">
2 <xsl:apply-templates select="." mode="if_template" />
3 </xsl:template>
4 <xsl:template match="*[position()=last()]" mode="if_template">
5 <xsl:value-of select="@atr" />
6 </xsl:template>
7 <xsl:template match="*|/" mode="if_template" />
i think the input file is processed as follows
1)the template from line 1 is instantiated three times, for each c element.
2)each time the current node list contains all three c elements and if you test "position()=last()" on line 2, it would be "true" only the third time when the third element is the current node. But not because it's 'last child of its parent' as you state, but becase it's the last element in the current node list as xslt1.0 spec chapter 4 Expressions states - the context position comes from the position of the current node in the current node list. ???
2)APPARENTLY FALSE:say the line1 template is instantiated with the first c element as current node. apply-templates on line2 then evaluates the select and gets the first c element only - this becomes the new current node list. the current node becomes the only element in the node list.
3)APPARENTLY FALSE:template on line4 is matched, because current node list contains just one node and position()=last()=1.
from your previous post i also don't see, why should you get different result if you replace line 2 with <xsl:if test="position()=last()"> etc
thanks for your endless(i hope) patience ...