The expression
parent::a[position()=1]
selects all the parents of the the context node that are called a, and then selects the first of these. Of course, a node can only have one parent, so this doesn't work.
You want
if test="not(parent::a/preceding-sibling::a)"
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference