cancel
Showing results for 
Search instead for 
Did you mean: 

Amount File Formatting in XSL mapping

former_member699292
Discoverer
0 Kudos

Hi Guru(s):

I have an XSLT mapping within an File to BPM scenario. The Flat file has an amount field of 13 characters, and reads a value like 16.10, followed by trialing whitespace to fill out the 13 positions.

I am able to read this file properly with a file adapter (have content conversion), which I am mapping to a BPM input.

I have an XSLT mapping that trasnfrms the file output to the BPM input. After the transformation, sometimes, the <SignedAmount> attribute has a non-conforming output, something like: 1610.0000000000002

Is this a bug in XSLT. How can this be resolved.

BTW: I am using XI3.0 SP14.

XSLT Code snippet:

<SignedAmount>

<xsl:choose>

<xsl:when test="DebitCreditIndicator[1]='D'">

<xsl:value-of select="number(ChargeAmount[1] * '100')"/>

</xsl:when>

<xsl:otherwise>

<xsl:value-of select="number(ChargeAmount[1] * '-1' * '100')"/>

</xsl:otherwise>

</xsl:choose>

</SignedAmount>

However, I get to see different behaviors for different nodes on the output.

In particular, note the second ISEG node:

- <ISEG>

<SignedAmount>79</SignedAmount>

</ISEG>

- <ISEG>

<SignedAmount>1610.0000000000002</SignedAmount>

</ISEG>

The Actual Output of the file adapter looks fine as below:

<Detail>

<ChargeAmount>0.79</ChargeAmount>

</Detail>

<Detail>

<ChargeAmount>16.10</ChargeAmount>

</Detail>

Thanks

Feroz

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member699292
Discoverer
0 Kudos

Hi:

Thanks very much for responding. However, here are the concerns:

1. I plan to use the sum function to validate that the Amount Totals. I am running into a situation 4494.55 comparing to 4494.55000000000002

2. On my xslt, I do not understand why the for-each loop generates different outputs for amount fields.

Thanks

Feroz

Former Member
0 Kudos

Why don't you try formating the number with XSL?

<xsl:template match="/">

<html>

<body>

<xsl:value-of select='format-number(500100, "#.00")' />

<br />

<xsl:value-of select='format-number(500100, "#.0")' />

<br />

<xsl:value-of select='format-number(500100, "###,###.00")' />

<br />

<xsl:value-of select='format-number(0.23456, "##%")' />

<br />

<xsl:value-of select='format-number(500100, "#######")' />

</body>

</html>

</xsl:template>

http://www.w3schools.com/xsl/func_formatnumber.asp