Sometimes it is useful to have "global" variables.
They get processed once against the input document.
Example:
<xsl:transform xmlns:xsl=''> <xsl:variable name="citations" select="//citations"/>
and then use it later:
<xsl:apply-templates select="$citations[@id=$ref]"/>
Here's that example: globals.xsl citations.xml