is it possible to use "attribute value templates" in variable or param?

xslt

Solution

You can use a `select` expression to define the variable, using the `concat` function to join the various bits together:

<xsl:variable name="imgsrc" select="concat($base, '/', @filename, '.jpg')"/>
<img src="{$imgsrc}" />

This is also more efficient than the `<xsl:value-of>` approach because by using `select` you're setting the variable to a string value directly rather than creating a tree fragment containing a text node which then has to be converted back into a string when you reference the variable.

Problem

this is nice and short: ``` <img src="{$base}/{@filename}.jpg" /> ``` but sometimes you need to reuse the `src`, so it turns into this: ``` <xsl:variable name="imgsrc"> <xsl:value-of select="$base">/<xsl:value-of select="@filename"> <xsl:text>.jpg</xsl:text> </xsl:variable> <img src="$imgsrc" /> ``` According to http://www.w3.org/TR/xslt#dt-attribute-value-template you can't use the "curly brackets interpolation syntax" outside of literal element attributes, but there might be a not-so-hacky hack to do the trick? I'm lazy, I know.

Original source