It is seen in the smooks website that it supports EDI generation. But there is no way to specify the configuration for an edi writer (as in the case of reader defined in schema http://www.milyn.org/xsd/smooks/edi-1.1.xsd).
In some old posts in certain forums, I have seen that smooks is planning for such a writer. Is it available? Thanks in advance.
I managed to do this using the same schema used in the unedifact:reader
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>
The result is a HashMap withe the elements readed. Now that i have objets i can make any modifications and after that i use the document interchange factory: ex D96AInterchangeFactory
D96AInterchangeFactory factory = D96AInterchangeFactory.getInstance();
UNEdifactInterchange41 unEdifactInterchange = (UNEdifactInterchange41) map.get("unEdifactInterchange");
StringWriter ediOutStream = new StringWriter();
factory.toUNEdifact(unEdifactInterchange, ediOutStream);
Finally i can use toString() to get my document:
System.out.println("document: " + ediOutStream.toString());
According to the Smooks website:
Smooks can read and write data formats other than XML, including EDI, CSV, JSON, YAML, Java. To read non-XML data, you typically need to configure a for that data type. Writing data typically involves configuring a template that operates on the event stream produced by the (as in the case of XSLT), or on the beans in the BeanContext (as in the case of FreeMarker). You can also simply allow Smooks to serialize the event stream produced by the input reader, which will produce XML, giving an effective NNN to XML transformation by simply configuring a reader for the input source.
So, yes, there is a possibility to generate EDI with Smooks.