How to define an ISA segment in smooks?

I am creating ANSI.X12 posts in a java program using smooks. I myself define X12 messages using xml files (from theirs http://www.milyn.org/schema/edi-message-mapping-1.2.xsd

). Most of them work well enough, but I have a problem with the ISA segment. I have defined it 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="&#10;" 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 am inserting lines of correct length, this is mostly useful. The problem is with the component separator ( ^

in this case). The ISA segment defines which characters are special characters used to separate segments, elements, etc. When I put "^"

as a value in ComponentElementSeparator

, it becomes escaped (of course) as it is a special char and smooks doesn't know that my ISA segment is an ISA special segment.

I get

ISA*00*          *00*          *01*000000987654321*01*000000123456789*141031*1656*U*00401*000002388*0*T*?^

      

where should he be

ISA*00*          *00*          *01*000000987654321*01*000000123456789*141031*1656*U*00401*000002388*0*T*^

      

(note at ?

the end before ^

).

The only workaround I've gotten so far is to put a few different chars in medi:delimiters

like <medi:delimiters segment="&#10;" field="*" component="&lt;" sub-component="~" escape="?" />

, but that inevitably creates problems as soon as that char appears in the data somewhere. This is especially frustrating since the message doesn't even use any components that need to be split.

I couldn't find any information about this in the documentation on smooks, but there must be some way to do it somehow. After all, X12 is one of two reasons I know someone will be using smooks in the first place (the other is EDIFACT).

Does anyone know the correct way to insert ISA into smooks message description?

+3


source to share


1 answer


It might be late, but I ran into a problem. The problem I identified (if you are using EJC to generate) is that at the end of each segment output stage the following is added:

writer.write(EDIUtils.concatAndTruncate(nodeTokens, DelimiterType.FIELD, delimiters));

      

If the last separator (which ISA.ComponentElementSeparator has) will be truncated, unless it is escaped, which is not the desired behavior for this particular scenario. You don't have an answer yet, but you want to raise the source code of the problem.



Added issue definition and possible direction here: https://github.com/smooks/smooks/issues/114

UPDATE: when using EJC, set the following:

 <medi:import truncatableSegments="false" ....

      

0


source







All Articles