on 07-27-2011 9:02 AM
We have an issue :
The input flat file is as follows:
Atest 1'Btest2'Ctest3'Dtest4'Etest5'Ftest6
I have to use message trsnform bean to convert this to xml , its a simple thing to do , the challenge comes when this structure has not definite position :
for example the file may come like this as well
Atest 1'Btest2'Ctest3'Etest5'Ftest6
Dtest4' is not generated and other fields push back the position (they dnt maintain the position)
in the similar way it can happen to any fields in that file.
I tried MTB to generate the fields , but everyting works when all the fields are populated , but when they shift positons due to missing fields
For example normal XML will be in this format for the above conversion:
Recordset
Record
<a>test1<a/>
<b>test2<b/>
.......... and so on
But when the position shifts
For the above example when Dtest4 is missing
Recordset
Record
<a>test1<a/>
<b>test2<b/>
<c>test3<c/>
<d>test5<d/>
<e>test6<e/>
Infact they are apperaing the field one place above in the xml , I have configured key values in a proper way , I could not use fixed.lenght as the lenght of the fields are not same always .....
Hi,
MessageTransform bean will not work in your case as for the csv files, the number of fields need to be fixed.
So if your file came like : Atest 1'Btest2'Ctest3''Etest5'Ftest6, with an additional ' for the missing segment, the bean would have been able to recognise the empty segment.
With the field seperator itself missing, the MTB will not know the missing segment and consider the next available segment in its place.
Try to go for a 2 step conversion. Define the first structue as containing only one field with field seperator as new line character.
Then, in a message map, convert from this structure to the actual sender structure.
Alternatively, you can go for a custom adapter module as well.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what parameter have you configured?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
77 | |
9 | |
9 | |
7 | |
6 | |
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.