Jan 26, 2012 at 8:27 PM
Edited Jan 26, 2012 at 8: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, 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);
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!