XSLT is not a macro language. Variable represent values, not bits of text that you can substitute textually into an expression. If you have a value 3 or "London" in an expression like [x = 3] or [x = "London"] then you can replace the value with a variable reference. In these examples you can also replace x with a variable $X, but if the value of $X is "x", then you are doing a quite different test: instead of testing whether the element x is equal to 3 or "London", you are testing whether the String "x" is equal to 3 or London (which it isn't).
Similarly if you write X/$Y (which is actually allowed in XPath 2.0), and the value pf $Y is "fred", then this is the same as writing X/"fred", not the same as X/fred.
To replace an element name by a variable that holds the element name, change X/Y to X/*[name()=$VAR].
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference