Reputation: 21
I'm having a XSL which will take an XML as input and will return another XML in a desired format. The issue im facing is there is numeric field which is fine when it have as value such as 4.00..5.00 etc, but when it is 0 the input is coming as .00 instead of 0.00. is there any way i can changes .00 to 0.00? This is how my current XSL looks like: the Variable "Amount_57LV_ID2" is the one i would like to change below. if it is .00 should show 0.00
<?xml version="1.0" encoding="WINDOWS-1252"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
-<xsl:template match="/">
<!-- Root template -->
-<Declaration language="FR" type="TVA_DECM" model="1">
-<Year>
<xsl:value-of select="/R570018A/Report_Header_S5/Year_PO_ID11"/>
</Year>
-<Period>
<xsl:value-of select="/R570018A/Report_Header_S5/Period_Number_PO_ID13"/>
</Period>
-<FormData>
-<xsl:for-each select="R570018A/UDC___Full_View_of_F0005_for_Transfer_57_LV_Driver_S1/Vat_Cross_Ref_57_LV_Print_S3/Print_F570018A_S6">
-<NumericField id="{AccountNumber_ID1}">
<xsl:value-of select="Amount_57LV_ID2"/>
</NumericField>
</xsl:for-each>
</FormData>
</Declaration>
</Declarer>
</Declarations>
</eCDFDeclarations>
</xsl:template>
</xsl:stylesheet>
Upvotes: 0
Views: 727
Reputation: 116993
Instead of:
<xsl:value-of select="Amount_57LV_ID2"/>
try:
<xsl:value-of select="format-number(Amount_57LV_ID2, '0.00')"/>
This is assuming the data always needs a precision of exactly 2 decimal places.
Upvotes: 1