在smooks网站上可以看到它支持EDI生成。但是无法指定edi写入器的配置(就像在模式http://www.milyn.org/xsd/smooks/edi-1.1.xsd中定义的读取器的情况一样)。
在某些论坛的一些旧帖子中,我看到smooks正在计划这样一个作家。有空的吗?提前谢谢。
发布于 2015-03-03 22:24:53
我成功地使用了unedifact中使用的相同模式
Smooks-config:
<?xml version="1.0"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.4.xsd">
<import file="/org/milyn/edi/unedifact/d96a/message-bindingconfig.xml" />
<import file="/org/milyn/smooks/edi/unedifact/model/r41/bindings/unedifact-interchange.xml" />
<core:exports>
<core:result type="org.milyn.payload.JavaResult"/>
</core:exports>
</smooks-resource-list>结果是一个带有已读元素的HashMap。现在我有了objets,可以进行任何修改,之后我将使用文档交换工厂: ex D96AInterchangeFactory
D96AInterchangeFactory factory = D96AInterchangeFactory.getInstance();
UNEdifactInterchange41 unEdifactInterchange = (UNEdifactInterchange41) map.get("unEdifactInterchange");
StringWriter ediOutStream = new StringWriter();
factory.toUNEdifact(unEdifactInterchange, ediOutStream);最后,我可以使用toString()来获取我的文档:
System.out.println("document: " + ediOutStream.toString());发布于 2014-03-11 01:08:08
根据Smooks website的说法
XML可以读写
以外的数据格式,包括EDI、CSV、JSON、YAML、Java。要读取非XML数据,通常需要为该数据类型配置。写入数据通常涉及配置一个模板,该模板操作由生成的事件流(如XSLT),或操作BeanContext中的bean(如FreeMarker)。您还可以简单地允许Smooks序列化输入读取器生成的事件流,这将生成XML,只需为输入源配置一个读取器,就可以实现从NNN到XML的有效转换。
所以,是的,使用Smooks生成EDI是可能的。
https://stackoverflow.com/questions/12794416
复制相似问题