>Are there ways of setting permanent variables for this purpose? i.e. the variable is stored for the context node at the present time and can be referenced later in the program?
>For example setting a variable in a portion at the beginning of the XSLT script for a given context node, and then referencing it later when the context has changed, but not change the value...
That's exactly the way variables work. They depend on the static and dynamic context at the point where the variable is bound (initialized), not the point where it is used.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference