finding all anceters of the node.most urgent

how to find out all ancesters of the node.
ex:










in the above XML file , can we find all ancestors of f?

Can you use this, or something like it:

<xsl:template match="f">
  <xsl:text>f ancestors are:</xsl:text> 
  <xsl:for-each select="ancestor::*">
   <xsl:value-of select="name()"/>
    <!-- Output a comma if it's not the last one in
         the node set that for-each is going through. -->
   <xsl:if test="position() != last()">
   <xsl:text>,</xsl:text>
   </xsl:if>
  </xsl:for-each>
</xsl:template>