dynamically set variable name

webmasterbeta

New Member
Hi,
In my xslt, I would like to dynamically set a variable's name and use its value for calculation based on whether the name of the node is "a1", "a2", or "a3". Is there any way to get the value "col_size" to be evaluated as the value of variable "a*_len"? The code below makes $col_size to be "a*_len" not the value of "a*_len". Can such thing be done in xslt? Thank you for your help.

<xsl:variable name="a1_len">30</xsl:variable>
<xsl:variable name="a2_len">20</xsl:variable>

<xsl:template match="a1 | a2 | a3" >

<xsl:variable name="col_size" select="concat(name(), '_len')"/> //problem here

<textarea readonly="readonly" name="name" rows="1" cols="30">
<xsl:variable name="row_len" select="floor(string-length(.) div $col_size)"/>
<xsl:attribute name="rows">
<xsl:value-of select="$row_len + 1"/>
</xsl:attribute>

<xsl:value-of select="."/>
</textarea>
</xsl:template>


~Sue
 
Top