EdiFact
Here you can find an Edifact parser and converter library.
For more information about UN/EDIFACT see : http://www.unece.org/trade/untdid.
Before using the package please consider the followings:
Our packages are intended to use by professionals.
Accordingly, we suggest to use these packages only in case you are a
software developer who can read the java sources without any further help.
You are allowed to use and modify the code, in order to integrate it into your application without any restriction,
on your own risk, of course. This package has been developed for a special use case, and your approach to the
parsing could obviously be different. That is the reason why we offer the full source code to you.
What you need?
Fist of all you will need the source code of the parser what is available here.
Secondly, of course, you will need a code which use this parser. It could be something like this:
package hu.reliance.edifact.sample;
import hu.reliance.edifact.EdifactHandler;
import hu.reliance.edifact.Field;
import hu.reliance.edifact.Segment;
import hu.reliance.edifact.config.Config;
import hu.reliance.edifact.exception.EdifactException;
import hu.reliance.edifact.parser.Edifact;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import org.xml.sax.InputSource;
public class Sample implements EdifactHandler
{
public void handleSegment(Segment pSegment)
{
System.out.println(pSegment);
}
public void handleField(Field pField)
{
System.out.println(pSegment);
}
public void error(String pMessage, int pSegment, int pField)
{
System.out.println("Error occured at segment "+pSegment+" field "+pField+". Message:"+pMessage);
}
public static void main(String args[])
{
try
{
Edifact parser = new Edifact(new InputSource(new FileReader(new File("test.edi"))),new Sample());
parser.addConfig(new Config("TEST",new File("config.xml")));
parser.convert();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (EdifactException e)
{
e.printStackTrace();
}
}
}
When you take a look at the code above, you can find three literal in the main method:
- test.edi is the Edifact file to be parsed.
- TEST_1_1 is the name and the version of the segment, and
- config.xml tells the parser how a segment should be mapped.
All of the resources above (Sample.java, test.edi, config.xml) are bounded into the code package
If you have any further question, please do not hesitate to contact us at info at reliance.hu or call +36 30 397 63 48.



