If you want the template that includes the image tag to be processed, you should replace the <xsl:value-of select="country"/>
with xsl:apply-templates select="country">
. With that you will call the templates you defined for each country.
<xsl:template match="/">
<table class="headingstable">
...
<xsl:for-each select="weeklyevents/event">
<tr>
<td class="headingsmid"><xsl:value-of select="title"/></td>
<td class="headingsmid"><xsl:apply-templates select="country"/></td>
<td class="headingsmid"><xsl:value-of select="date"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
So if you have a template for each country, as you proposed, if there is <country>UK</country>
in the source document, it will match one of your country
templates:
<xsl:template match="country[. = 'UK']">
<img src="../uk.jpg" />
</xsl:template>
and the generated <td>
will be:
<td class="headingsmid">
<img src="../uk.jpg"/>
</td>
In case the source contains an "unsupported" country (one you don't have a template for), it will simply print out the text:
<td class="headingsmid">AUS</td>
If you can derive your file name from the country code, then you can make your stylesheet even simpler.
If you are using XSLT 2.0 replace all your country
templates for:
<xsl:template match="country">
<img src="../{lower-case(.)}.jpg" />
</xsl:template>
If you are limited to XSLT 1.0 (if processing is done in a browser, for example), you won't have lower-case()
but can use translate()
like this:
<xsl:template match="country">
<img src="../{translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')}.jpg" />
</xsl:template>