//Create HTML Currency Entity References in XSL

Example XSL Sheet Below (Note, for each CURRENCY element found, the full set of available currency symbols is rendered. This is just for the example. The key line is :-

<pre lang=”xsl”>

<xsl:text disable-output-escaping=”yes”>€</xsl:text>

</pre>

<pre lang=”xsl”>

<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform“>

<xsl:apply-templates />

<xsl:template match=”CURRENCY”>
<xsl:call-template name=”currency_symbol”>
<xsl:with-param name=”iso_code”>GBP</xsl:with-param>
</xsl:call-template>
<xsl:call-template name=”currency_symbol”>
<xsl:with-param name=”iso_code”>EUR</xsl:with-param>
</xsl:call-template>
<xsl:call-template name=”currency_symbol”>
<xsl:with-param name=”iso_code”>JPY</xsl:with-param>
</xsl:call-template>
<xsl:call-template name=”currency_symbol”>
<xsl:with-param name=”iso_code”>USD</xsl:with-param>
</xsl:call-template>

</xsl:template>

<xsl:template name=”currency_symbol”>
<xsl:param name=”iso_code”/>
<xsl:choose>
<xsl:when test=”$iso_code=’JPY'”>
<xsl:text disable-output-escaping=”yes”>¥</xsl:text>
</xsl:when>
<xsl:when test=”$iso_code=’EUR'”>
<xsl:text disable-output-escaping=”yes”>€</xsl:text>
</xsl:when>
<xsl:when test=”$iso_code=’USD'”>
<xsl:text disable-output-escaping=”yes”>$</xsl:text>
</xsl:when>
<xsl:when test=”$iso_code=’GBP'”>
<xsl:text disable-output-escaping=”yes”>£</xsl:text>
</xsl:when>
<xsl:otherwise>
NoSymbol
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

</pre>

By |2008-07-23T11:38:02+00:00July 23rd, 2008|XSL|0 Comments

About the Author: