Feedback
Did this article resolve your question/issue?

   

Article

How to Parse multi input file using XML Converters

Information

 
TitleHow to Parse multi input file using XML Converters
URL NameHow-to-Parse-multi-input-file-using-XML-Converters
Article Number000176508
EnvironmentDataDirect-DD XMLConverter Serv-Windows-7
Question/Problem Description
How to Parse multi input file using XML Converters. 

Can the converters process an EDI with header information, which is basically in a CSV format? 

For Example: 

123|XX|10:00AM|ISA*00* ~ 

Is there a way to configure the converters to parse this or must that header data be stripped before it's passed to the EDI Converter? 

A requirement is to be able to access the header information and process the data in the X12 transaction. The output would be a pipe-delimited file. 

DDTestData_JSON is JSON format, but the X12 is apart of one of the data elements of the JSON. 
 
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
For pipe-delimited 

1. Since each of the EDI messages contains separate X12 envelopes, the simplest option would be the brute force one where you treat each line as a separate message, something like this: 

BufferedReader br = new BufferedReader(new FileReader("DD_testBatch.txt")); 
String line; 
while ((line = br.readLine()) != null) { 

StringReader sr = new StringReader(line.split("|")[13]); 

.... convert using StringReader sr as the input... 

br.close(); 

There are lots of other ways. 

2. You could use the CSV converter, set the delimiter to |, and process the input from there, then send it to the next converter (maybe using XSLT or XQuery in between) 

3. You could run the whole thing from DDXQ, reading the input as CSV using | and writing the output through the converter. 

3.a. You could use DDXQ as in 3., but merge all the message bodies into one message for processing. This would let you build one acknowledgement message when using the Analyze function. 

4. You could create a filtered InputStream or Reader class that ignored the parts of the file you don't care about. 

And there are still more, but these are some options. 

For JSON: 

You can use the JSON converter in pretty much the same way. It would take a little bit of code, but this is what DDXQ was designed to do. 

Also, to parse the JSON, you could use something like the Jackson toolkit. 

ArrayNode root = (ArrayNode)new ObjectMapper().readValue(...inputstream..., JsonNode.class).get("Transactions"); 
for (JsonNode node : root) { 

StringReader sr = new StringReader(node.get("data").asText(); 

.... convert using StringReader sr as the input... 
Workaround
Notes
Last Modified Date8/15/2016 9:17 PM
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.