What kind of processor are you running your XSLT and at what version ?
If you're running Saxon, you could make use of the "Extension Functions".
Between the following:
You should be able to manipulate an incoming string appropriately to use as an XPath. For full documentation on these functions see the official site.
Im' not as familiar with the other processors available and specific functions they may have, but their may be something similar.