简体   繁体   English

如何在Java中将NCPDP标准格式消息转换为xml格式?

[英]How to convert NCPDP standard format message to xml format in java?

i'm trying to find, is there any library available that convert NCPDP format message to XML format in java?. 我试图找到,是否有可用的库将NCPDP格式的消息转换为Java中的XML格式? In Mirth Connect tool, there's direct option to convert NCPDP to XML using this lines: 在Mirth Connect工具中,有直接选项可以使用以下几行将NCPDP转换为XML:

var serializationProperties = SerializerFactory.getDefaultSerializationProperties('NCPDP');
SerializerFactory.getSerializer('NCPDP', serializationProperties, null).toXML(ncpdpmessage);

and Mirth Connect giving this functionality, so they have use some api or library in backend to convert NCPDP to XML. 和Mirth Connect提供了此功能,因此他们在后端使用了一些api或库将NCPDP转换为XML。 i want to do same, but in java. 我想做同样的事情,但是在java中。

Any help appreciated. 任何帮助表示赞赏。

Mirth Connect uses its own implementation of NCPDP serializer. Mirth Connect使用自己的NCPDP串行器实现。 You may find it in datatype-ncpdp-shared.jar in the \\extensions\\datatype-ncpdp folder. 您可以在\\ extensions \\ datatype-ncpdp文件夹中的datatype-ncpdp-shared.jar中找到它。

In short, the NCPDPSerializer.toXml() code does the following: 简而言之,NCPDPSerializer.toXml()代码执行以下操作:

NCPDPReader ncpdpReader = new NCPDPReader(serializationSegmentDelimiter, serializationGroupDelimiter, serializationFieldDelimiter);
StringWriter stringWriter = new StringWriter();
XMLPrettyPrinter serializer = new XMLPrettyPrinter(stringWriter);
ncpdpReader.setContentHandler(serializer);
ncpdpReader.parse(new InputSource(new StringReader(source)));
return stringWriter.toString();

So if you want to utilize the same you probably need all other related Mirth libraries. 因此,如果要使用相同的库,则可能需要所有其他相关的Mirth库。 Since NCPDPReader extends SAXParser and does not rely on any other Mirth packages you may try to build your own library based on that. 由于NCPDPReader扩展了SAXParser并且不依赖于任何其他Mirth软件包,因此您可以尝试基于此构建自己的库。 (Check copyrights and license notes before you start doing so.) You may also try to find other NCPDP Java parser such as JParser. (在开始这样做之前,请检查版权和许可说明。)您还可以尝试查找其他NCPDP Java解析器,例如JParser。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM