Saturday, December 09, 2006

XSLT Templates

If you need to add format for display transformation, you can use XSLT templates.

Numeric Templates
<xsl:template name="currencyValue">
<xsl:param name="Number" />
<xsl:value-of select="format-number($Number,'#,###,##0.00')" />
</xsl:template>

<xsl:template name="integerValue">
<xsl:param name="Number" />
<xsl:value-of select="format-number($Number,'####0')" />
</xsl:template>

For invoke them
...

<xsl:variable name="totalRows" select ="count(reg/amount)" />
<xsl:variable name="totalCustomer" select ="sum(reg/amount)" />
...

<xsl:call-template name="currencyValue">
<xsl:with-param name="Number" select="$totalCustomer" />
</xsl:call-template>
...
<xsl:call-template name="integerValue">
<xsl:with-param name="Number" select="$totalRows" />
</xsl:call-template>
...
The ouput
2,333.01
561

No comments:

Google