Java 中有没有好的 X12 解析器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11077963/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 03:41:25  来源:igfitidea点击:

Is there any good X12 parser in Java?

javaedix12

提问by Chandana

Is there any good X12 parser in Java which can process Walmart 810 specification?

Java 中有没有好的 X12 解析器可以处理 Walmart 810 规范?

EDI example:

EDI示例:

ISA*00*          *00*          *16*102096559TEST  *14*PARTNERTEST    *071214*1406*U*00040*810000263*1*T*>
  GS*IN*102096559TEST*PARTNER*20071214*1406*810000263*X*004010
    ST*810*0001
      BIG*20050205*6463367*20050202*3376103367
      REF*IA*123456170*X5T
      REF*DP*00017
      REF*MR*0020
      N1*SU*SUPPLIER NAME
      N1*ST*WAL-MART 100*UL*0078742000992
        N3*406 SOUTH WALTON BLVD
        N4*BENTONVILLE*AR*72712 
      ITD*05*15*****45
      DTM*011*20050205
      FOB*CC
      IT1**1080*EA*3.61**IN*001719653*UP*022108955228*UK*            00221089552284       
        PID*F****ITEM DESCRIPTION
        SAC*A*I410***2350*******02
      TDS*387530
      CAD*T***RDWT*ROADWAY**BM*123456789
      ISS*1080*EA*100*LB
      CTT*1
    SE*19*0001
  GE*1*810000263
IEA*1*810000263

回答by Kushan

Try this, edireader

试试这个,编辑器

The parser differentiates between ANSI X.12 and EDIFACT EDI standards by inspection and uses a factory pattern to construct an appropriate parser subclass.

解析器通过检查区分 ANSI X.12 和 EDIFACT EDI 标准,并使用工厂模式来构造适当的解析器子类。

The parser can be embedded within your Java application in the same way as you would an XML parser, avoiding the file-based and proprietary interfaces often used with conventional EDI translators.

解析器可以像嵌入 XML 解析器一样嵌入到您的 Java 应用程序中,避免了传统 EDI 转换器经常使用的基于文件的专有接口。

回答by óscar López

Try using Smooks. From the page:

尝试使用Smooks。从页面:

Smooks is an extensible framework for building applications for processing XML and non XML data (CSV, EDI, Java, etc) using Java.

Smooks 是一个可扩展的框架,用于构建使用 Java处理 XML 和非 XML 数据(CSV、EDI、Java 等)的应用程序。

回答by Francis Upton IV

If you are open to a commercial product, have a look at the Oakland Data Transformer. It's written in Java, has an Eclipse-based designer, and a Java API or integration with Apache Camel, Mule ESB, and OSGi Blueprint. You can easily graphically map it to XML, database, Java objects or other things.

如果您对商业产品持开放态度,请查看Oakland Data Transformer。它是用 Java 编写的,有一个基于 Eclipse 的设计器,以及一个 Java API 或与 Apache Camel、Mule ESB 和 OSGi Blueprint 的集成。您可以轻松地以图形方式将其映射到 XML、数据库、Java 对象或其他事物。

You will need to contact Oakland Software when you download it to get the specifications for the X12 4010 810 which is what you are using.

您在下载时需要联系 Oakland Software 以获取您正在使用的 X12 4010 810 的规格。

回答by eppye.bots

you could try bots: http://bots.sourceforge.netit is not java, but python. it is not a 'library' but an application. handles x12 OK, incl 810. You can translate it to the format you need (xml, csv, flat file)

你可以试试机器人:http: //bots.sourceforge.net它不是 java,而是 python。它不是一个“库”,而是一个应用程序。处理 x12 OK,包括 810。您可以将其转换为您需要的格式(xml、csv、平面文件)

回答by Sridhar

We can use apache camel, camel is very easy and extensible solution of this,

我们可以使用apachecamel,camel是非常容易和可扩展的解决方案,

This will give a json objects, afterthat we can parse the json objects then get the values.

这将给出一个 json 对象,之后我们可以解析 json 对象然后获取值。

XmlJsonDataFormat xmlJsonFormat = new XmlJsonDataFormat();
        xmlJsonFormat.setEncoding("UTF-8");
        xmlJsonFormat.setForceTopLevelObject(true);
        xmlJsonFormat.setTrimSpaces(true);
        xmlJsonFormat.setRootName("newRoot");
        xmlJsonFormat.setSkipNamespaces(true);
        xmlJsonFormat.setRemoveNamespacePrefixes(true);
    //  xmlJsonFormat.setExpandableProperties(Arrays.asList("d", "e"));

          from("file:sftpdata/x12files")
            .log("Before unmarshal with SmooksDataFormat:").log("${body}")
            .unmarshal(new SmooksDataFormat("smooks-config1.xml"))
            .log("After unmarshal with SmooksDataFormat:").log("${body}")
           .marshal(xmlJsonFormat)
             .log("After marshalling with Json library:").log("${body}")
             .process(new X12Processor()).log("X12 file processed")
            .to("mock:result");