Nell' Xsl viene utilizzato come una function nello jscript, se scrivo un template per formattare le date:
<xsl:template name="DecodeDate">
<xsl:param name="DateUTC"/>
<xsl:choose>
<xsl:when test="$DateUTC != '' ">
<xsl:value-of select="substring($DateUTC , 9
,2)"/>/<xsl:value-of select="substring($DateUTC , 6 ,2)
"/>/<xsl:value-of select="substring($DateUTC , 1 ,4) "/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$DateUTC" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="FormatCurrency">
<xsl:param name="Impo"/>
<xsl:value-of select="translate(format-number($Impo, '##.00'),'.',',')"/>
</xsl:template>
Lo posso poi richiamare all'interno del file come una funzione senza dover ogni volta ripetere il codice:
<xsl:call-template name="DecodeDate">
<xsl:with-param name="DateUTC" select="Entities/HotelAccommodation/DateEnd/."/>
</xsl:call-template>
<xsl:call-template name="FormatCurrency">
<xsl:with-param name="Impo" select="sum(/Entities/HotelAccommodationRate/BaseAmount/.)"/>
</xsl:call-template>