on 07-22-2010 9:21 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.