25 points · by alexprengere · 1mo ago · 17 comments
You define the syntax tree once, then parse, validate, or pretty-print messages against that structure. It works by converting the syntax tree to a state machine of possible transitions between segments.
The real challenge was to discover what the tree was. Like wayfair order listings, cargo delivery messages, which are also similar to how Rhenus does them. Every vendor has their own format and standards.
The hardest part was europeans taking 15 day holidays every couple of months leaving work to someone else who had to start over.
I wrote a C library to parse the messages with callbacks in the style of Expat. There's binding for Perl to make it a bit easier to use. EDIFACT, X12 and Tradacoms are supported.
Anyways, unlikely anyone might need it these days, but there are some Perl scripts which can interpret the EDIFACT "directories" (basically message schemas), so you don't have to build your own message syntax definitions. It should be possible to convert the XML output that it generates into the Python needed to define message syntax, element definitions, etc.
Best of luck with it - there's a whole world of crazy industry standards to explore.
Oh, and consulting is a possibility if anyone needs it ;-)
There are hundreds of "substandards" per industry. For example for clothes or medicine, most vendors have custom fields outside of the standard which MUST be interpreted/sent or everything falls apart
EDIFACT normally has (possibly repeating, possibly nesting) segment groups and a lot of code trying to handle EDIFACT skips over that.
At this point, I'm pretty convinced that if you're running into EDI (or its sister formats like HL7) processing issues, its because you've got the wrong data structure in place or you aren't keeping your rules up to date. Once you've got the right architecture in place, you can easily manage 100s of provider/partner-specific rules with one person at 20% time. If you don't your whole company is going to be dealing with data integrity issues forever