Remember that id() searches the document that contains the context node.
When you've got two documents like this it's always a good idea to declare global variables:
<xsl:variable name="staticDoc" select="/"/>
<xsl:variable name="dynamicDoc" select="document('dynamic.xml')"/>
Assume that the context node is the <variable> element in the static doc.
In XSLT 2.0 you can do
<xsl:value-of select="id(@name, $dynamicDoc)"/>
In 1.0 it has to be:
<xsl:variable name="id" select="@name"/>
<xsl:for-each select="$dynamicDoc">
<xsl:value-of select="id($id)"/>
</xsl:for-each>
The for-each here serves no purpose other than to change the context node.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference