XSLT is a functional programming language, and it doesn't use variables in the same way as a procedural programming language. You need to think about your problem in a different way. If you describe your problem, rather than describing the way you would solve it in a procedural language, then we may be able to help you.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference