on 04-21-2008 12:12 PM
Hi All,
I am using XSLT mapping.I want to get the field in the receiver side with the leading zeros.Source field: XSD :decimal and length is 10.If input is 12345, i have to get 0000012345.
Can anybody please solve the problem and guide me if u know .
Hi,
use the user defind function with the following code.
while( inputField.length() < Integer.parseInt(totalLength))
{
inputField = 0 + inputField ;
}
return inputField;
warm regards
mahesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This UDF can also help you.
// pad a to this length if a is numeric
int targetLength = 40;
// determine if the material is numeric or alphanumeric
try {
// an exception is thrown if a is not an integer
Integer.parseInt(a);
// the material is numeric, proceed with formatting
// Create a buffer for the new string
StringBuffer buffer = new StringBuffer(targetLength);
// If it's already long enough, return the original string
if (a.length()>=targetLength) { return a; }
// Loop through and add zeros to the buffer
for (int q=0; q<targetLength-a.length();q++) { buffer.append("0"); }
// append the material
buffer.append(a);
// return the new result
return buffer.toString();
} catch (NumberFormatException e) {
// the material is alpha or non-integer, return the material unchanged
return a;
}
regards,
Anu Singhal
Hi,
There can be two ways to do this.
Eithere you do it in xslt itself or just use the Arithmetic function -
> FormatNum as shown below.
Source -
> xsltmapping -
> FormatNum -
> Target
OR
Source -
> FormatNum -
> xsltmapping -
> Target
Double click on FormatNum and enter 10 zero's in the upper input box.
Regards,
Sarvesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
Have u tried <xsl:number format="000000000" >?
Thanks,
Tuhin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.