<xsl:variable> allows you to associate a variable with a string, node list, or result tree fragment.
Variables are "single assignment" (no side effects)
Variables are lexically scoped
Variables assigned inside a conditional only apply inside that conditional. This is rarely correct:
<xsl:if test="$foo"> <xsl:variable name="bar">...</xsl:variable> </xsl:if>
Usually, you want to put the conditional inside the variable
<xsl:variable name="bar"> <xsl:if test="$foo">...</xsl:if> </xsl:variable>