Error Converting to HTML on Straight EDI X12

Jan 26, 2012 at 9:27 PM
Edited Jan 26, 2012 at 9:29 PM

I am receiving an X12 message (270 and 271 in x12 5010) over a socket and it contains the binary character 0x1D in it to separate the fields. This is apparently choking up the X12HtmlTransformationService.Transform() function.

Here is my code doing this:

Stream ediFile = new FileStream(args[0], FileMode.Open, FileAccess.Read);
var htmlService = new X12HtmlTransformationService(new X12EdiParsingService(suppressComments: false));
var Parser = new X12Parser();
Interchange interchange = Parser.Parse(ediFile);
//String X12XML = interchange.Serialize();
String X12 = interchange.SerializeToX12(true);
string html = htmlService.Transform(X12);
//string html = htmlService.Transform(X12XML);
File.WriteAllText(args[1], html);

It is tossing the following XmlException on the htmlService.Transform(X12) line:
' ', hexadecimal value 0x1D, is an invalid character. Line 2, position 63.

I have traced down into the code and it is happening because the XSLT does not understand the binary character in the stream yet it is parsed just fine by the X12 Parser. That part it is talking about it segment-terminator attribute in the Interchange tag.

This is a valid X12 transaction and we do tens of thousands of these a day so I am not sure why it is failing here and not supporting. Is there a workaround I can use in the meantime for this to generate good HTML?

Thanks guys and keep up the good work!

Coordinator
Jan 26, 2012 at 11:02 PM

This probably needs to be xml encoded.  I'll look at it tonight and see I can check-in a fix.  Do you have a test file that I can use? Preferrably de-identified?

Jan 26, 2012 at 11:26 PM
I can get you one tomorrow. I am gone from the office for the day so it would be tomorrow morning at the earliest.

Sayle

Sent from my iPad

On Jan 26, 2012, at 5:02 PM, "dstrubhar" <notifications@codeplex.com> wrote:

From: dstrubhar

This probably needs to be xml encoded. I'll look at it tonight and see I can check-in a fix. Do you have a test file that I can use? Preferrably de-identified?

Jan 27, 2012 at 4:10 PM
I have attached a sample X12 271 I am trying to do this with. I garbled a lot of data to obscure any PHI so I hope I didn't kill something important in it.

Sayle

On Thu, Jan 26, 2012 at 5:25 PM, A. Sayle Matthews <khirok@gmail.com> wrote:
I can get you one tomorrow. I am gone from the office for the day so it would be tomorrow morning at the earliest.

Sayle

Sent from my iPad

On Jan 26, 2012, at 5:02 PM, "dstrubhar" <notifications@codeplex.com> wrote:

From: dstrubhar

This probably needs to be xml encoded. I'll look at it tonight and see I can check-in a fix. Do you have a test file that I can use? Preferrably de-identified?

Read the full discussion online.

To add a post to this discussion, reply to this email (x12parser@discussions.codeplex.com)

To start a new discussion for this project, email x12parser@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Coordinator
Feb 1, 2012 at 3:50 PM

I did not find the attachment.

I was not able to reproduce a file, because windows doesn't recognize the 0x1D as a displayable character.

I was able to get it to work with other displayable characters that were greater 0x1E.

My suggestion to you is to write a small routine before you run the x12parser that will replace the 0x1D characters with another delimiter character before it transforms to XML.

Let me know if that works for you, or try again to attach your sample file. 

Feb 2, 2012 at 8:00 PM
I have attached a scrubbed X12 270 in 5010 format. You may want to open this in an editor such as vi or notepad+ as if you open and save in notepad Windows will scrub the non-printable characters. Plus in the other editors it will give you a representation of the non-displayable characters.

In the meantime I will write a script that will replace the characters to printable ones before processing as you suggested.

On Wed, Feb 1, 2012 at 9:50 AM, dstrubhar <notifications@codeplex.com> wrote:

From: dstrubhar

I did not find the attachment.

I was not able to reproduce a file, because windows doesn't recognize the 0x1D as a displayable character.

I was able to get it to work with other displayable characters that were greater 0x1E.

My suggestion to you is to write a small routine before you run the x12parser that will replace the 0x1D characters with another delimiter character before it transforms to XML.

Let me know if that works for you, or try again to attach your sample file.

Read the full discussion online.

To add a post to this discussion, reply to this email (x12parser@discussions.codeplex.com)

To start a new discussion for this project, email x12parser@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Coordinator
Mar 15, 2012 at 2:28 AM

This is now fixed in release 2.2.3