Link to home
Start Free TrialLog in
Avatar of Darius
DariusFlag for Lithuania

asked on

xslt 1.0 - Formatting string (Removing leading zeros)

Hi guys,

I am facing an issue with string formatting to remove leading zeros.

when
input = '000111100' or 111100
result is: 111100  - all ok!

when
input = '01111111111111111111101110'
result is: "1111111111111111100000000"
expected result is: 1111111111111111111101110

Function
<xsl:variable name="test1" select="string(number($input))" />

Open in new window

It looks like does not work for large numbers.
Please share if you have an explanation or logic function to remove leading zeros only on any size of value.

Thank You,
Darius
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<xsl:variable name="test1" select="string(number($input))" />

Open in new window


would then become

<xsl:variable name="test1">
            <xsl:call-template name="cut-leading-zeros">
                <xsl:with-param name="str" select="$input"></xsl:with-param>
            </xsl:call-template>
</xsl:variable>

Open in new window

Avatar of Darius

ASKER

Thank you Geert,

much appreciate