A couple of things.
Firstly, you have a lot of use of "//" - in my opinion overuse. This will always slow down your XSLT - more so the larger the XML input. Don't use it unless you need to. It's definitely not needed in the template match property.
Secondly, inside the for-each instruction the current context is an atomic value (a string), so the "//" at the start of the xpath has no meaning, because it tries to find all nodes in the current context - and you can't for this in an atom value.
Thirdly, in the [@id=.] predicate the "." refers to the current element - inside the xpath, i.e. the parent bb element you are searching, not the string value returned by the tokenize.
Taking all those points the following is an example that does what you want:
Code:
<xsl:variable name="aa" select="/aa"/>
<xsl:template match="bb">
<bb name="{@name}">
<xsl:attribute name="ref">
<xsl:for-each select="tokenize(@ref, ' ')">
<xsl:text>//aa/</xsl:text>
<xsl:value-of select="$aa/bb[@id=current()]/@name"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:attribute>
</bb>
</xsl:template>