Back-End Developer
unread,Mar 3, 2023, 12:31:24 AM3/3/23Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Smooks Development
This is my code snippet:
public class Main {
protected static String runSmooksTransform() throws IOException, SAXException, SmooksException {
Smooks smooks = new Smooks("to-xml/smooks-config.xml");
try {
StringWriter writer = new StringWriter();
smooks.filterSource(new StreamSource(new FileInputStream("to-xml/PAXLST.edi")), new StreamResult(writer));
return writer.toString();
} finally {
smooks.close();
}
}
public static void main(String[] args) throws IOException, SAXException, SmooksException {
System.out.println("\n\n==============Message In==============");
System.out.println(readInputMessage());
System.out.println("======================================\n");
String messageOut = Main.runSmooksTransform();
System.out.println("==============Message Out=============");
System.out.println(messageOut);
System.out.println("======================================\n\n");
}
private static String readInputMessage() throws IOException {
return StreamUtils.readStreamAsString(new FileInputStream("to-xml/PAXLST.edi"));
}
}
and this is my pom.xml
<dependency>
<groupId>org.milyn.edi.unedifact</groupId>
<artifactId>d99b-mapping</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.milyn.edi.unedifact</groupId>
<artifactId>d16a-mapping</artifactId>
<version>1.7.1.0</version>
</dependency>
<dependency>
<groupId>org.milyn.edi.unedifact</groupId>
<artifactId>d15b-mapping</artifactId>
<version>1.7.1.0</version>
</dependency>
<dependency>
<groupId>org.milyn.edi.unedifact</groupId>
<artifactId>d07a-mapping</artifactId>
<version>1.7.1.0</version>
</dependency>
<dependency>
<groupId>org.milyn.edi.unedifact</groupId>
<artifactId>d15a-mapping</artifactId>
<version>1.7.1.0</version>
</dependency>
</dependencies>
</project>
When I run project everything work fine I mean I am trying to convert edi file to xml and smooks generate xml from edi file like in the following:
This is my edi file:
UNB+UNOA:4+LOCK:02+CBP-ACE-TEST:02+041013:1901+16++ACE'UNG+PAXLST+LOCK:02+CBP-ACE-TEST:02+041013:1901+16+UN+D:03B:'UNH+PAXLST16+PAXLST:D:03B:UN'BGM+10+LOCKKH04103101+4'RFF+RFA:03'TDT+11++++LOCK:172'DTM+132:20041230:102'NAD+VW+0000041153:109++AOMAD:CHRIS::::1+11107 SUNSET HILLS ROAD+RESTON+VA:163:5+20190'ATT+2++M*M*M*M*M'DTM+329:19350919:102'EMP+4+++1++8'NAT+2+US::5'DOC+5K+P100971204141'LOC+91+VA:163'LOC+91+US:162'DOC+39+15504141'LOC+91+US:162'UNT+16+PAXLST16'UNE+1+16'UNZ+1+16'
and smooks's generate xml like this:
<env:unEdifact xmlns:env="urn:org.milyn.edi.unedifact.v41">
<env:UNB>
<env:syntaxIdentifier>
<env:id>UNOA</env:id>
<env:versionNum>4</env:versionNum>
</env:syntaxIdentifier>
<env:sender>
<env:id>LOCK</env:id>
<env:codeQualifier>02</env:codeQualifier>
</env:sender>
<env:recipient>
<env:id>CBP-ACE-TEST</env:id>
<env:codeQualifier>02</env:codeQualifier>
</env:recipient>
<env:dateTime>
<env:date>041013</env:date>
<env:time>1901</env:time>
</env:dateTime>
<env:controlRef>16</env:controlRef>
<env:applicationRef>ACE</env:applicationRef>
</env:UNB>
<env:group>
<env:UNG>
<env:groupId>PAXLST</env:groupId>
<env:senderApp>
<env:id>LOCK</env:id>
<env:codeQualifier>02</env:codeQualifier>
</env:senderApp>
<env:recipientApp>
<env:id>CBP-ACE-TEST</env:id>
<env:codeQualifier>02</env:codeQualifier>
</env:recipientApp>
<env:dateTime>
<env:date>041013</env:date>
<env:time>1901</env:time>
</env:dateTime>
<env:groupRef>16</env:groupRef>
<env:controllingAgencyCode>UN</env:controllingAgencyCode>
<env:messageVersion>
<env:versionNum>D</env:versionNum>
<env:releaseNum>03B</env:releaseNum>
</env:messageVersion>
</env:UNG>
<env:interchangeMessage xmlns:c="urn:org.milyn.edi.unedifact:un:d03b:common" xmlns:paxlst="urn:org.milyn.edi.unedifact:un:d03b:paxlst">
<env:UNH>
<env:messageRefNum>PAXLST16</env:messageRefNum>
<env:messageIdentifier>
<env:id>PAXLST</env:id>
<env:versionNum>D</env:versionNum>
<env:releaseNum>03B</env:releaseNum>
<env:controllingAgencyCode>UN</env:controllingAgencyCode>
</env:messageIdentifier>
</env:UNH>
<paxlst:PAXLST>
<paxlst:BGM>
<c:C002>
<c:e1001>10</c:e1001>
</c:C002>
<c:C106>
<c:e1004>LOCKKH04103101</c:e1004>
</c:C106>
<c:e1225>4</c:e1225>
</paxlst:BGM>
<paxlst:RFF>
<c:C506>
<c:e1153>RFA</c:e1153>
<c:e1154>03</c:e1154>
</c:C506>
</paxlst:RFF>
<paxlst:Segment_group_2>
<paxlst:TDT>
<c:e8051>11</c:e8051>
<c:e8028></c:e8028>
<c:C220>
</c:C220>
<c:C001>
</c:C001>
<c:C040>
<c:e3127>LOCK</c:e3127>
<c:e1131>172</c:e1131>
</c:C040>
</paxlst:TDT>
<paxlst:DTM>
<c:C507>
<c:e2005>132</c:e2005>
<c:e2380>20041230</c:e2380>
<c:e2379>102</c:e2379>
</c:C507>
</paxlst:DTM>
</paxlst:Segment_group_2>
<paxlst:Segment_group_4>
<paxlst:NAD>
<c:e3035>VW</c:e3035>
<c:C082>
<c:e3039>0000041153</c:e3039>
<c:e1131>109</c:e1131>
</c:C082>
<c:C058>
</c:C058>
<c:C080>
<c:e3036_-_-1>AOMAD</c:e3036_-_-1>
<c:e3036_-_-2>CHRIS</c:e3036_-_-2>
<c:e3036_-_-3></c:e3036_-_-3>
<c:e3036_-_-4></c:e3036_-_-4>
<c:e3036_-_-5></c:e3036_-_-5>
<c:e3045>1</c:e3045>
</c:C080>
<c:C059>
<c:e3042_-_-1>11107 SUNSET HILLS ROAD</c:e3042_-_-1>
</c:C059>
<c:e3164>RESTON</c:e3164>
<c:C819>
<c:e3229>VA</c:e3229>
<c:e1131>163</c:e1131>
<c:e3055>5</c:e3055>
</c:C819>
<c:e3251>20190</c:e3251>
</paxlst:NAD>
<paxlst:ATT>
<c:e9017>2</c:e9017>
<c:C955>
</c:C955>
<c:C956>
<c:e9019>M*M*M*M*M</c:e9019>
</c:C956>
</paxlst:ATT>
<paxlst:DTM>
<c:C507>
<c:e2005>329</c:e2005>
<c:e2380>19350919</c:e2380>
<c:e2379>102</c:e2379>
</c:C507>
</paxlst:DTM>
<paxlst:EMP>
<c:e9003>4</c:e9003>
<c:C948>
</c:C948>
<c:C951>
</c:C951>
<c:C950>
<c:e9007>1</c:e9007>
</c:C950>
<c:e3494></c:e3494>
<c:e9035>8</c:e9035>
</paxlst:EMP>
<paxlst:NAT>
<c:e3493>2</c:e3493>
<c:C042>
<c:e3293>US</c:e3293>
<c:e1131></c:e1131>
<c:e3055>5</c:e3055>
</c:C042>
</paxlst:NAT>
<paxlst:Segment_group_5>
<paxlst:DOC>
<c:C002>
<c:e1001>5K</c:e1001>
</c:C002>
<c:C503>
<c:e1004>P100971204141</c:e1004>
</c:C503>
</paxlst:DOC>
<paxlst:LOC>
<c:e3227>91</c:e3227>
<c:C517>
<c:e3225>VA</c:e3225>
<c:e1131>163</c:e1131>
</c:C517>
</paxlst:LOC>
<paxlst:LOC>
<c:e3227>91</c:e3227>
<c:C517>
<c:e3225>US</c:e3225>
<c:e1131>162</c:e1131>
</c:C517>
</paxlst:LOC>
</paxlst:Segment_group_5>
<paxlst:Segment_group_5>
<paxlst:DOC>
<c:C002>
<c:e1001>39</c:e1001>
</c:C002>
<c:C503>
<c:e1004>15504141</c:e1004>
</c:C503>
</paxlst:DOC>
<paxlst:LOC>
<c:e3227>91</c:e3227>
<c:C517>
<c:e3225>US</c:e3225>
<c:e1131>162</c:e1131>
</c:C517>
</paxlst:LOC>
</paxlst:Segment_group_5>
</paxlst:Segment_group_4>
</paxlst:PAXLST>
<env:UNT>
<env:segmentCount>16</env:segmentCount>
<env:messageRefNum>PAXLST16</env:messageRefNum>
</env:UNT>
</env:interchangeMessage>
<env:UNE>
<env:controlCount>1</env:controlCount>
<env:groupRef>16</env:groupRef>
</env:UNE>
</env:group>
<env:UNZ>
<env:controlCount>1</env:controlCount>
<env:controlRef>16</env:controlRef>
</env:UNZ>
</env:unEdifact>
however I want to change another edifact message format like this:
UNB+IATB:1+6XPPC+LHPPC+940101:0950+1'
UNH+1+PAORES:93:1:IA'
MSG+1:45'
IFT+3+XYZCOMPANY AVAILABILITY'
ERC+A7V:1:AMD'
IFT+3+NO MORE FLIGHTS'
TVL+240493:1000::1220+FRA+JFK+DL+400+C'
PDI++C:3+Y::3+F::1'
APD+74C:0:::6++++++6X'
TVL+240493:1740::2030+JFK+MIA+DL+081+C'
PDI++C:4'
APD+EM2:0:1630::6+++++++DA'
UNT+13+1'
UNZ+1+1'
I am getting exception like this:
Mapping Model 'PAORES:93:1:IA' not found in supplied set of Mapping model.
What exactly do am I? can anyone suggest any solution for this?