cancel
Showing results for 
Search instead for 
Did you mean: 

Sender File (FCC) - Content of File into single XML Tag

Former Member
0 Kudos

Hi,

Input file

This is Line1

This is Line2

Expected Sender File adapter FCC into XML

<Document>

.<File>

..<Content> This is line 1 This is line2</content>

.</File>

</Document>

FCC is giving the following output with the below config,

File.fieldNames = Content

File.fieldSeparator = '0x1A' (HexaDecimal rep for EndOfFile)

<Document>

.<File>

..<Content>This is line 1</content>

..<Content>This is line 2</content>

.</File>

</Document>

How can i read the complete file into a single XML tag?

I am aware of other options (AdapterModules or Javamapping). But i want to keep it simple to FileAdapter using FCC or using MessageTransformBean (if possible)

-SM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

FCC donse't work here, So i wrote a simple Java map inside Execute method to convert the content to the required format.

public void execute(InputStream in, OutputStream out) throws StreamTransformationException{

StringBuilder sb = new StringBuilder();

try {

BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));

while ((line = reader.readLine()) != null) {

sb.append(line).append("\r\n");

}

} finally {

in.close();

}

After i had the input string, i formatted it to get the required output as XML ...

<Document>

.<File>

..<Content> This is line 1 This is line2</content>

.</File>

</Document>

former_member187339
Active Contributor
0 Kudos

Hi Siva,

Reading the entire input into single XML node is not possible (atleast i was never successful) using FCC...because whenever a newline character comes in the file, the adapter consider it as a separate node.

Regards

Suraj