Adding custom XPath functions to XSL
This article shows you how to add context aware XPath functions to an XSL transformation. This is done by a hack using reflection.
http://www.codeproject.com/soap/xslhack.asp