Reputation: 3
I'm working with XSLT and trying to remove all zeros present before and after the numbers. Examples:
000000004552000 needs to translate to 4552.
Any ideas how to get this done using xslt? Thanks in advance!
Upvotes: 0
Views: 161
Reputation: 163322
Please always say what XSLT version you are using.
In 2.0, you can use replace(num, '^0+|0+$', '')
.
In 1.0, it's more difficult (everything is).
To remove leading zeroes, use string(number(.))
.
To remove trailing zeroes, I think you need a recursive named template with the logic:
if $param mod 10 = 0
then call yourself with param = $param div 10
else $param
Upvotes: 1