XSLT is a functional language -- among other things this means that variables are immutable -- once given a value they cannot be changed.
The solution to this specific problem:
Change:
To:
When the corrected transformation is applied to the provided XML document, the wanted result is produced.