Avatar of Darius
Darius
Flag 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
XML* XSLT* XSL

Avatar of undefined
Last Comment
Gertone (Geert Bormans)

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Gertone (Geert Bormans)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Gertone (Geert Bormans)

<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

Darius

ASKER
Thank you Geert,

much appreciate
Gertone (Geert Bormans)

welcome
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck