cancel
Showing results for 
Search instead for 
Did you mean: 

Message Tranform Bean content conversion

Former Member
0 Kudos

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 .....

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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

former_member854360
Active Contributor
0 Kudos

what parameter have you configured?

Former Member
0 Kudos

xml.a.keyfieldvalue=a

same for b,c,d,e,f

xml.fieldnames= test1, test2..........

xml.fieldseparator= '

xml.keyfieldname=Key

and rest all are common ones to be used for MTB

Former Member
0 Kudos

Have you tried to set only:

xml.fieldnames= test1, test2..........

xml.fieldseparator= '

And no set the key parameters?

Former Member
0 Kudos

yes I tried one by one ...once it comes to 4th field and above its behaving in this fashion