Per impostare il valore (testuale) di una varibile xsl si può usare il seguente costrutto:
<xsl:variable name="current_stage">
<xsl:choose>
<xsl:when test="$competition_id = '2' and count(/SportsContent/Stage[@stId = '4']/Standing/Team) > 0">4</xsl:when>
<xsl:when test="$competition_id = '2' and count(/SportsContent/Stage[@stId = '4']/Standing/Team) = 0">5</xsl:when>
</xsl:choose>
</xsl:variable>
o, più in generale
<xsl:variable name="var">
<xsl:choose>
<xsl:when test="...expr1...">10</xsl:when>
<xsl:when test="...expr2...">10</xsl:when>
<xsl:otherwise>15</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Il costrutto precedente non è utilizzabile per assegnare dei fragment tree alla variabile; si deve utilizzare il seguente costrutto:
<xsl:variable name="stage" select="Stage[@stId =$current_stage and $competition_id = '2'] | Stage[contains(@type, 'regular_season') and $competition_id != '2']"/>
o, più in generale, pensando ad un if-else
select = valore-per-if[condizione] | valore-per-else[not(condizione)]