Parsing of DELJIT messages?

26 views
Skip to first unread message

Joske Vermeulen

unread,
Jun 21, 2021, 6:09:31 AMJun 21
to Smooks Users
Hi,

for integration tests I need to verify DELJIT messages.
I've looked at the edi-to-java example, but fail to understand how the fixed length segment parts are processed.
Do I need to provide this in the xml?  I don't see the length listed in there, so how does it know that?

Any help will be greatly appreciated!

Kind regards,

Jos

Claude Mamo

unread,
Jun 21, 2021, 8:49:00 AMJun 21
to smook...@googlegroups.com
Greetings Joske. The edi-to-java example demonstrates Smooks in a non-EDIFACT scenario. DELJIT belongs to EDIFACT right? You should look at the edifact examples.

Claude
<xsd:simpleType name="alpha0-70">
<xsd:restriction base="xsd:string">
<xsd:minLength value="0"/>
<xsd:maxLength value="70"/>
</xsd:restriction>
</xsd:simpleType>
Claude

--
You received this message because you are subscribed to the Google Groups "Smooks Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smooks-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smooks-user/248ae9b4-e278-47f2-96c2-546b5ad3bf6en%40googlegroups.com.

Joske Vermeulen

unread,
Jun 21, 2021, 9:52:06 AMJun 21
to Smooks Users
Thanks for the very quick reply!

I'm no expert in DELJIT, but I do think it indeed is a EDIFACT file.
Was a bit confused with the edifact example in the sense that I could not find it. Was looking in my smooks 1.7.1 clone. Did find the smooks-examples project now with the edifact-to-xml example.
I guess I can configure it also to read directly to java?

Other question:
In my DELJIT description I see that it has one or more NAD segments. I just need to configure the xsd and smooks will create one or more corresponding nodes in the XML or objects in Java?

thanks,

Jos

Joske Vermeulen

unread,
Jun 21, 2021, 12:51:46 PMJun 21
to Smooks Users
Hi,

I've been looking into the edifact-to-xml example, but have a few issues:
- smooks-config.xml points to https://www.smooks.org/xsd/smooks-2.0.xsd and edifact-2.0.xsd.  These links don't work. However, a link to smooks-1.2.xsd does work?!
- Main.java mentions Smooks can be configured programmatically with an EdifactReaderConfiguration. I can't find this one. I can find an UNEdifactReaderConfiguration, but this doesn't have the setMessageTypes method.

And for my understanding: would I still need to add the minLength/maxLength for all fields in the DELJIT message, or is this configured already in Smooks?

Kind regards,

Chris

Claude Mamo

unread,
Jun 21, 2021, 2:57:12 PMJun 21
to smook...@googlegroups.com
- smooks-config.xml points to https://www.smooks.org/xsd/smooks-2.0.xsd and edifact-2.0.xsd.  These links don't work. However, a link to smooks-1.2.xsd does work?!

At the moment Smooks 2 XSDs are hosted on https://www.smooks.org/v2/ (e.g., https://www.smooks.org/v2/xsd/smooks-2.0.xsd).

- Main.java mentions Smooks can be configured programmatically with an EdifactReaderConfiguration. I can't find this one. I can find an UNEdifactReaderConfiguration, but this doesn't have the setMessageTypes method.

UNEdifactReaderConfiguration was renamed to EdifactReaderConfigurator in Smooks 2 so I'm assuming that you're not referencing the latest release from your POM.

And for my understanding: would I still need to add the minLength/maxLength for all fields in the DELJIT message, or is this configured already in Smooks?

No need. These rules are described in the DFDL schemas which smooks-edifact-cartridge provides for EDIFACT.

Claude

Joske Vermeulen

unread,
Jun 22, 2021, 10:12:19 AMJun 22
to Smooks Users
Again, thanks for the quick reply.
It seems quite a lot has changed between 1.7.1 and 2.0.0-M3.
Can you give an indication which dependencies I would need to include for reading EDIFACT messages into Java objects?
I'm having issues getting packages imported.  Could also be the Artifactory server in our organisation, I'm not sure, not an expert in that.

Jos

Claude Mamo

unread,
Jun 23, 2021, 1:33:59 AMJun 23
to smook...@googlegroups.com
Probably we need to provide an edifact-to-java example but these dependencies should be sufficient for you: https://github.com/smooks/smooks-examples/blob/v1.0.2/java-to-edifact/pom.xml#L30-L44.

Claude

Joske Vermeulen

unread,
Jun 23, 2021, 10:15:11 AMJun 23
to Smooks Users
Ok, thanks, that helped get the import right:
<dependency>
  <groupId>org.smooks.cartridges.edi</groupId>
  <artifactId>smooks-edifact-cartridge</artifactId> 
  <version>2.0.0-M3</version>
</dependency>
<dependency>
  <groupId>org.smooks.cartridges.edi</groupId> 
  <artifactId>d96a-edifact-binding</artifactId>
  <version>2.0.0-M3</version>
</dependency>
<dependency>
  <groupId>org.smooks.cartridges.edi</groupId>
  <artifactId>edifact-schemas</artifactId>
  <version>2.0.0-M3</version>
  <classifier>d96a</classifier>
</dependency>


It seems in our version, we use d96a version of Edifact.

Do have an issue with a nullpointer in org.apache.daffodil though...
I wrote following method:
public String parseDelJit(String message) {
    final Smooks smooks = new Smooks();
    smooks.setReaderConfig(new EdifactReaderConfigurator("/d96a/EDIFACT-Messages.dfdl.xsd").setMessageTypes(Arrays.asList("DELJIT")));
    final StringWriter writer = new StringWriter();
    smooks.filterSource(new StringSource(message), new StreamResult(writer));
   return writer.toString();
}


And call it from a simple test with following DELJIT file:
@Test
public void DelJitTest() throws IOException, SAXException {
    String message = "UNH DELJIT D96AUNA10010BGM 3020212241720458870DTM137202106031720 203NAD SEE521J 92NAD BY737 92LOC 11086 LOC159086 SEQ 34570156DTM194202105280814 203GIR 4665023107 FYYV4162UM2M2617547 VI1 LILIN30753320 MNQTY131+000000000001DTM 2202106021720 203UNT 12 \n";
    String parsed = edifactTasks.parseDelJit(message);
}


However, this gives a nullpointer exception in org.apache.daffodil:
org.smooks.api.SmooksException: Failed to filter source
...
Caused by: org.apache.daffodil.exceptions.Abort: Invariant broken. Runtime.scala - Leaked exception: java.lang.NullPointerException
java.lang.NullPointerException
at org.apache.daffodil.io.BucketingInputSource.fillBucketsToIndex(InputSource.scala:261)
at org.apache.daffodil.io.BucketingInputSource.areBytesAvailable(InputSource.scala:329)
...
at org.smooks.cartridges.dfdl.parser.DfdlParser.parse(DfdlParser.java:183)
at org.smooks.engine.delivery.sax.ng.SaxNgParser.parse(SaxNgParser.java:86)

Any idea what could be going wrong here?

Op woensdag 23 juni 2021 om 07:33:59 UTC+2 schreef Claude:

Claude Mamo

unread,
Jun 25, 2021, 3:11:54 AMJun 25
to smook...@googlegroups.com
The stack trace does look unusual to me. Open an issue if the error persists.

Claude

Joske Vermeulen

unread,
Jun 25, 2021, 5:13:47 AMJun 25
to Smooks Users
Logged https://github.com/smooks/smooks-edi-cartridge/issues/139 for this.

Op vrijdag 25 juni 2021 om 09:11:54 UTC+2 schreef Claude:
Reply all
Reply to author
Forward
0 new messages