I am creating ANSI.X12 messages in a java program with the help of smooks. I'm defining the X12 messages myself using xml-files (with their http://www.milyn.org/schema/edi-message-mapping-1.2.xsd
). Most of it works well enough, but I do have a problem with the ISA-segment. I have it defined as such:
<?xml version="1.0" encoding="UTF-8"?>
<medi:edimap xmlns:medi="http://www.milyn.org/schema/edi-message-mapping-1.2.xsd">
<medi:description name="Some X12 Message Definition" version="1.0" />
<medi:delimiters segment=" " field="*"
component="^" sub-component="~" escape="?" />
<medi:segments xmltag="Segments">
<medi:segment segcode="ISA" xmltag="InterchangeControlHeader">
<medi:field xmltag="AuthorizationInformationQualifier" />
<medi:field xmltag="AuthorizationInformation"/>
<medi:field xmltag="SecurityInformationQualifier"/>
<medi:field xmltag="SecurityInformation"/>
<medi:field xmltag="InterchangeSenderQualifier"/>
<medi:field xmltag="InterchangeSenderID"/>
<medi:field xmltag="InterchangeReceiverQualifier"/>
<medi:field xmltag="InterchangeReceiverID"/>
<medi:field xmltag="InterchangeDate" type="Date" typeParameters="format=yyMMdd"/>
<medi:field xmltag="InterchangeTime" type="Date" typeParameters="format=HHmm"/>
<medi:field xmltag="InterchangeControlStandardsIdentifier"/>
<medi:field xmltag="InterchangeControlVersionNumber"/>
<medi:field xmltag="InterchangeControlNumber"/>
<medi:field xmltag="AcknowledgmentRequested"/>
<medi:field xmltag="UsageIndicator"/>
<medi:field xmltag="ComponentElementSeparator"/>
</medi:segment>
[...]
As long as I insert strings of the correct lengths, this is mainly usable. The problem is with the component separator (^
in this case). The ISA segment defines which chars are special chars used to separate segments, elements, etc. When I put "^"
as value into ComponentElementSeparator
, it becomes escaped (of course), since it is a special char, and smooks does not know that my ISA segment is the special ISA segment.
I get
ISA*00* *00* *01*000000987654321*01*000000123456789*141031*1656*U*00401*000002388*0*T*?^
where it should be
ISA*00* *00* *01*000000987654321*01*000000123456789*141031*1656*U*00401*000002388*0*T*^
(note the ?
at the end before the ^
).
The only workaround that I got so far, is to put some different char into medi:delimiters
such as <medi:delimiters segment=" " field="*" component="<" sub-component="~" escape="?" />
, but that is bound to create problems as soon as that char appears in the data somewhere. This is specially frustrating, as the message does not even use any components that have to be separated.
I could not find any information on that in the documentation of smooks, but there must be some way somehow to do it. After all, X12 is one of two reasons I know of, that anyone would use smooks in the first place (the other one beeing EDIFACT).
Anyone knows the correct way to insert ISA into my smooks message description?