|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
DFDL - Decimal to String with format |
« View previous topic :: View next topic » |
Author |
Message
|
Thomas2ab |
Posted: Wed Aug 27, 2014 9:30 am Post subject: DFDL - Decimal to String with format |
|
|
Acolyte
Joined: 07 Mar 2014 Posts: 51
|
Hi everyone,
Here is the situation:
I am having a xml as input message that i will transform to a plain text as output message.
The ouput message is represented as DFDL schema. I almost completed it, but here is a rule i'm not really sure how to do it.
From the input message, some fields will be decimal. Those fields will be string in the output message. Actually everything will be string in the output message.
The rule that is defined for the transformation is the following:
The output string has to be 5 number before the comma and 2 after.
For example:
Input=0 --> 00000,00 (also need to transform the '.' from the xml decimal to ',')
Input=1.1 --> 00001,10
Input=123456.789 --> 12345,78
Input=<> (empty) --> 00000,00
I thought about dfdl:textNumberPattern but I am not sure if there would be a rule that will be common for all of kind of decimal input I might receive.
Thanks a lot for your help,
Regards, |
|
Back to top |
|
 |
kimbert |
Posted: Wed Aug 27, 2014 1:03 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
You need the following settings:
- textNumberPattern="00000.00"
- textStandardDecimalSeparator= ","
I was not sure what this sentence was asking:
Quote: |
I thought about dfdl:textNumberPattern but I am not sure if there would be a rule that will be common for all of kind of decimal input I might receive. |
Feel free to explain if you still are not sure. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
Thomas2ab |
Posted: Thu Aug 28, 2014 4:23 am Post subject: |
|
|
Acolyte
Joined: 07 Mar 2014 Posts: 51
|
Thanks Kimbert, will try this and let you know! |
|
Back to top |
|
 |
Thomas2ab |
Posted: Mon Sep 15, 2014 5:54 pm Post subject: |
|
|
Acolyte
Joined: 07 Mar 2014 Posts: 51
|
Hello Kimbert,
That's me again
The rule kind of changed a bit.
The input is still a xsd decimal value, but the output should be as follow:
5 numbers for the integer part
3 numbers for the decimal part
No comma or any int/decimal separator.
For the integer part if the int input size is less than 5 numbers, then we should add '0' at the left.
For the decimal part, if the decimal input size is less than 3 numbers, then we should add '0' at the right.
Which would give for example:
Input=0 --> 00000000
Input=1 --> 00001000
Input=1.1 --> 00001100
Input=123456.789 --> 12345789
Input=<> (empty) --> 00000000
Of course if the input number is bigger then each part has to be truncate at the right:
For example:
Input=123456.789 (the int part has 6 numbers instead of 5 allowed)--> 12345789
Input=12345.7891 (the decimal part has 4 numbers instead of 3 allowed)--> 12345789
So all those rules would be possible to configure only in the dfdl element definition?
Thanks a lot!
Regards, |
|
Back to top |
|
 |
kimbert |
Posted: Tue Sep 16, 2014 12:51 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Sounds exactly like a COBOL external decimal with a virtual decimal point. DFDL can handle any COBOL type, so it can handle this one too.
You need a Text Number Pattern like this
The 'V' is the position of an implied decimal point. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
Thomas2ab |
Posted: Wed Sep 17, 2014 3:48 am Post subject: |
|
|
Acolyte
Joined: 07 Mar 2014 Posts: 51
|
Thanks Kimbert it looks perfect!
However, I guess I should set the textStandardDecimalSeparator="" right?
If so, the textStandardGroupingSeparator should be also = "" right? But in this case I am getting an error saying that both these properties cannot have the same values...
Furthermore, if I set the text number pattern like the way you told me, will it do the truncate part also?
For example:
Input=123456.789 (the int part has 6 numbers instead of 5 allowed)--> 12345789
Input=12345.7891 (the decimal part has 4 numbers instead of 3 allowed)--> 12345789
Just setting that text number pattern property is enough?
Thanks a lot!
Regards, |
|
Back to top |
|
 |
kimbert |
Posted: Wed Sep 17, 2014 4:00 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
textStandardDecimalSeparator is only used if the pattern contains a decimal point. So feel free to set it to whatever value you like.
Quote: |
I am getting an error saying that both these properties cannot have the same values |
Sounds like a defect - if both are set to the empty string then it should not be an error.
Quote: |
Furthermore, if I set the text number pattern like the way you told me, will it do the truncate part also?
For example:
Input=123456.789 (the int part has 6 numbers instead of 5 allowed)--> 12345789
Input=12345.7891 (the decimal part has 4 numbers instead of 3 allowed)--> 12345789 |
Think about how this number is being processed by IIB.
If that does not work, add a Trace node to the flow and look at the message tree. Think about how the value changes between the input, the message tree and the output.
Either way, you should write repeatable, automated test cases for all of these scenarios _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|