The position() function returns the position of a node within the sequence of nodes currently being processed. This has nothing to do with its position in the source tree.
To find out the position of a node in the source tree, use xsl:number or count(preceding-sibling::*), or suitable variations.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference