Created
March 10, 2011 01:01
-
-
Save greystate/863374 to your computer and use it in GitHub Desktop.
Mapping currency codes to currency symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <xsl:variable name="currency-mapper"> | |
| <currency code="USD">$</currency> | |
| <currency code="EUR"><![CDATA[€]]></currency> | |
| <currency code="YEN"><![CDATA[¥]]></currency> | |
| <currency code="GBP"><![CDATA[£]]></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