¿Qué puedo hacer para que este código funcione?XSLT: puedo declarar una variable globalmente y luego asignarle un valor
<xsl:choose>
<xsl:when test='type = 6'>
<xsl:variable name='title' select='root/info/title' />
</xsl:when>
<xsl:when test='type = 7'>
<xsl:variable name='title' select='root/name' />
</xsl:when>
<xsl:otherwise>
<xsl:variable name='title'>unknown</xsl:variable>
</xsl:otherwise>
</xsl:choose>
<div class='title'>
<xsl:value-of select='$title'/>
</div>
Esto no funciona porque cuando hago <xsl:value-of select='$title'/>
, $title
está fuera de alcance. Traté de agregar la línea <xsl:variable name='title'/>
fuera del alcance, pero eso tampoco funcionará, porque cuando llamo a <xsl:variable name='title' select='root/info/title' />
por ejemplo, ya he configurado esta variable antes. ¿Cómo debería resolver esto?
Buena pregunta, +1. Ver mi respuesta para tres soluciones diferentes. :) –