on 12-17-2009 3:17 PM
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
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
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.