on 11-17-2007 12:23 AM
hi,
Could anybody pls tell me how do i truncate the leading zeros in the incoming file structure.
Thanks,
Chinna
YOu can write java code to do this in a UDF.
refer this link:
http://www.stylusstudio.com/xsllist/200301/post01150.html
Regards,
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your replies..
Regds,
Chinna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check this thread, i laready answered it there.
For you i pasting the solution here.
Write a UDF like this ..
public class test {
public static void main(String[] args) {
System.out.println(args[0].replaceAll("^0*",""));
}
}
Also you can use XSLT for this.
Try the XPath function number($string) in your XSLT and see if it does what you want. Since it turns any XPath object into a number, the leading zeros won't appear.
Use it ike this
<xsl:variable name="a">
<xsl:call-template name="removeLeadingZeros">
<xsl:with-param name="phone">
<xsl:value-of select="EVENT/ContactPhone"/>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:template name="removeLeadingZeros">
<xsl:param name="phone"/>
<xsl:message>
<xsl:value-of select="$phone"/>
</xsl:message>
<xsl:choose>
<xsl:when test="starts-with($phone,'0')">
<xsl:call-template name="removeLeadingZeros">
<xsl:with-param name="phone">
<xsl:value-of
select="substring-after($phone,'0' )"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$phone"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Regards
Aashish Sinha
PS : Reward Point if Helpful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello everyone,
Thanks for the replies. I have a problem. I have written a USD for truncating the zeros. when i was trying to test it by giving some constant values, using the display queue option i see a processing log window pops up and the hangs up for some time without giving the output results. I tried it number of times but the same thing pops up.
You help would be appreciated.
Thanks,
Chinna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
While mapping you can create an udf which will suppess the zeroes while getting mapped with the target field..
thanx pankaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Reddy,
There are functions available in message mapping like ceil ,floor , round andformatnumbe...
These functions are capable of fulfilling your requirement .
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Chinna,
use FormatNumber function and give just ####### and you get the result with out zeros.
I also had the similar requirement and i just used this function instead of UDF
Thanks,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use <b>ceil or floor or round</b> depending on your requirement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.