Reputation: 31
Hi I want to replace the last digit after the decimal point of a number with a character using xslt.
The number will be contained in a field, and for example, if the value of the field is 2586.48 it should be changed to some thing like, 0000025864Q. The total length of the field is 11.
The last digit after the decimal 8 is replaced with Q
Here are the replacements, 0 - }
1 - J
2 - K
3 - L
4 - M
5 - N
6 - O
7 - P
8 - Q
9 - R
Please help.
Upvotes: 0
Views: 270
Reputation: 116959
The question is a little ambiguous. Assuming that by "the last digit after the decimal point of a number" you actually mean the second decimal digit (i.e. hundredths), you could do:
<xsl:template match="field">
<xsl:copy>
<xsl:value-of select="format-number(floor(10 * .), '0000000000') "/>
<xsl:value-of select="translate(100 * . mod 10, '0123456789', '}JKLMNOPQR')"/>
</xsl:copy>
</xsl:template>
This assumes your input values are rounded to 2 decimal places.
Upvotes: 6