on ‎2008 Apr 21 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 .
Request clarification before answering.
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
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.