Converting XML to EDIFACT

1,108 views
Skip to first unread message

Gustav Sinder

unread,
May 7, 2015, 3:10:32 AM5/7/15
to smook...@googlegroups.com
Hi,

I'm looking at parsing/producing EDIFACT using Smooks in Apache ServiceMix. Parsing works really well and was a simple task to set up.
However, I can't wrap my head around how to produce EDIFACT from the very same XML format that the parser produces.

Found this old post on the topic but the solutions feels a bit cumbersome: http://milyn.996300.n3.nabble.com/Converting-from-XML-to-UNEDIFACT-in-Smooks-1-4-td5.html
The example Renat provided uses a number of classes found outside of Smooks, could there be a simpler way of doing it today?

Thanks
/Gustav

Tom Fennelly

unread,
May 8, 2015, 7:46:48 AM5/8/15
to smook...@googlegroups.com
Did you look at:
That stuff should let you go in both directions.

--
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 post to this group, send email to smook...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smooks-user/457a7e58-cec4-4ed7-8fd4-fac283199841%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gustav Sinder

unread,
May 8, 2015, 8:30:40 AM5/8/15
to smook...@googlegroups.com
I checked those earlier but they only seem to cover parsing, not producing. There's method in the factory class called toUNEdifact() that takes an Interchange and seems to do what I want.
However, I can't grasp how I easily create the Interchange from the XML.
Since the parser can produce an XML adhering to a specific schema couldn't an Interchange be parsed from an XML using the very same schema?

Thanks

Tom Fennelly

unread,
May 11, 2015, 9:13:55 AM5/11/15
to smook...@googlegroups.com

Gustav Sinder

unread,
May 12, 2015, 7:56:29 AM5/12/15
to smook...@googlegroups.com
Yes, the information there was very sparse though.
It shows the toUNEdifact() method but not how to produce the interchange.
However, a guy provided a link on one of the issues at the smooks github repo: http://stackoverflow.com/questions/12794416/smooks-edi-writer

I had to modify the manifest in milyn-smooks-all as documented here: http://milyn.996300.n3.nabble.com/Using-Smooks-1-5-1-in-an-OSGi-environment-td8671.html
Noticed this change was done in the latest POM on Github but I use 1.6.

This now works just fine in ServiceMix/Fuse!

Regards
Gustav

Tom Fennelly

unread,
May 13, 2015, 3:34:02 AM5/13/15
to smook...@googlegroups.com
I'm not sure what you mean. The examples at http://www.smooks.org/mediawiki/index.php?title=Smooks_v1.5_Examples#UN.2FEDIFACT show both reading and writing. Anyway, it sounds like you have found a solution.

David Bacon

unread,
Jun 12, 2015, 4:53:36 AM6/12/15
to smook...@googlegroups.com
I'm having the same issue here

I can see from the examples how to produce an edifact using the interchange

factory.toUNEdifact(interchange, ediOutStream);

but this interchange is created using 
UNEdifactInterchange interchange = factory.fromUNEdifact(ediInStream);
how do I create an interchange from an XML representation?

My goal is to be able to be able to transform from Edifact to XML which I'm able to do using the example but also to be able to transform from the same XML representation back to edifact

Thanks

David

Gustav Sinder

unread,
Jun 12, 2015, 9:00:33 AM6/12/15
to smook...@googlegroups.com
Hi,

You'll need to configure the smooks-config file according to the stackoverflow link in my previous mail.
That provides you with a hashmap that can be used to produce the interchange.

Regards
Gustav

--
You received this message because you are subscribed to a topic in the Google Groups "Smooks Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/smooks-user/n8cHUl02zRc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to smooks-user...@googlegroups.com.

To post to this group, send email to smook...@googlegroups.com.

farid ullah

unread,
Jun 13, 2015, 2:55:06 PM6/13/15
to smook...@googlegroups.com
Can someone please attach full project of converting xml to edi. I have been trying to convert but no success so far. Don't know how to use smooks to do this.

Michael Kassnel

unread,
Sep 15, 2015, 10:26:52 AM9/15/15
to Smooks Users
Hi,

I had similar issues with this a while ago so I posted some sample code on github: https://github.com/mescedia/xml-java-unedifact.
Hope this helps.

Regards Michael

Tom Fennelly

unread,
Sep 15, 2015, 10:40:43 AM9/15/15
to smook...@googlegroups.com
Thanks Michael.

--
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 post to this group, send email to smook...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages