cancel
Showing results for 
Search instead for 
Did you mean: 

MessageTransformBean - SimplePlain2XML - Multiple records on a single line

Former Member
0 Kudos

Hi,

I am trying to convert multiple record from a single line to multipe rows in an XML message with the MessageTransformBean.

If the record look like this it's working:

RECORD1textETC

RECORD2textETC

But the incoming message are all on a single line:

RECORD1textETCRECORD2textETC

Is there a way to add a linefeed to my incoming message after X characters, or to tell the adapter to split by length instead of spliting on the end of line?

Thanks,

Martin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Martin,

You can come up with one interface where in your mapping you can write the UDF to add a new line after some x characters or Probably we can come up with some script while breaks your one line string and add a new line and save it in a different location. You can pick from that location.

Regards,

---Satish

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

> Is there a way to add a linefeed to my incoming message after X characters, or to tell the adapter to split by length instead of spliting on the end of line?

This is not possible.

You have to write an adapter module which you place before the MessageTransformBean

Former Member
0 Kudos

I had to code a custom Module Adapter to do it.

Here's the main part of the module adapter EOLConvertBean...

...

Message msg = (Message) inputModuleData.getPrincipalData();

...

XMLPayload xmlpayload = msg.getDocument();

byte[] content = xmlpayload.getContent();

byte crlf = 0x0A; // end of line char

int current = 0; // current bytes read

ByteArrayOutputStream baos = new ByteArrayOutputStream();

int lines = content.length / recordLen; // record len = insert EOL after X recordLen

// TODO change for do while for 1x line record

for (int i = 0; i <= lines; i++) {

baos.write(content, current, recordLen);

baos.write(crlf);

current += recordLen;

}

xmlpayload.setContent(baos.toByteArray());

...

inputModuleData.setPrincipalData(msg);

...

Edited by: Martin Lavoie Rousseau on Oct 6, 2010 9:08 PM