user5458829
user5458829

Reputation: 163

Data transformation in XSLT

I have a filed value like "+000002030" need to convert it to "20.30" how can i do this using XSLT. This value "+000002030" is the dynamic one any value it can come.Please let me know how we can convert it.

Upvotes: 1

Views: 124

Answers (2)

Max Toro
Max Toro

Reputation: 28608

A solution in XSLT-2.0 would be

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

Upvotes: 0

michael.hor257k
michael.hor257k

Reputation: 117003

In XSLT 1.0, use:

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

To make this future-proof, use:

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

This will work the same in both XSLT 1.0 and XSLT 2.0.

Upvotes: 1

Related Questions