Skip to content

Instantly share code, notes, and snippets.

@greystate
Created March 10, 2011 01:01
Show Gist options
  • Select an option

  • Save greystate/863374 to your computer and use it in GitHub Desktop.

Select an option

Save greystate/863374 to your computer and use it in GitHub Desktop.
Mapping currency codes to currency symbols
<xsl:variable name="currency-mapper">
<currency code="USD">$</currency>
<currency code="EUR"><![CDATA[&euro;]]></currency>
<currency code="YEN"><![CDATA[&yen;]]></currency>
<currency code="GBP"><![CDATA[&pound;]]></currency>
</xsl:variable>
<xsl:variable name="currency-symbols" select="msxml:node-set($currency-mapper)" />
<xsl:template match="@currency" mode="symbol">
<xsl:variable name="symbol" select="$currency-symbols/currency[@code = current()]" />
<xsl:value-of select="$symbol" disable-output-escaping="yes" />
<xsl:if test="not($symbol)">$</xsl:if>
</xsl:template>
<!-- Usage: -->
<xsl:apply-templates select="product/@currency" mode="symbol" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment