If you decide to implement the solution using Smooks, I simply refer to the helpful information from the Smooks documentation:
Java for text (XML, CSV, EDI, etc.)
As stated in other parts of this guide, Smooks runs most of its time by processing a stream of SAX events generated by an input source of some type (XML, EDI, Java, etc.) and using these events to trigger the visitors logic. In the case of a Java source (see the previous section, βJava to Javaβ), Smooks uses an XStream to create this SAX event stream.
Sometimes, however, you just want to apply a template (like FreeMarker) to the Java Source object model and create XML, CSV, EDI, etc. You do not want to incur overhead by generating a stream of SAX events that you are not going to use. To do this, you must say that the main Smooks runtime does not generate an event stream. This can be done in one of two ways.
Calling setEventStreamRequired (false) on the JavaSource instance is delivered to Smooks.filterSource:
JavaSource javaSource = new JavaSource(orderBean); // Turn streaming off via the JavaSource... javaSource.setEventStreamRequired(false); smooks.filterSource(javaSource, result);
Or by disabling " http://www.smooks.org/sax/features/generate-java-event-stream " in the Smooks configuration:
<reader> <features> <setOff feature="http://www.smooks.org/sax/features/generate-java-event-stream" /> </features> </reader>
When applying the FreeMarker template, the name of the beans context template (i.e. the names used in your template) depends on the type of object in the JavaSource:
If the object is a Map, then the map instance becomes the context template, and so you can simply use the map input keys as bean names in your template. For non-map objects, the JavaSource class takes an Object Class SimpleName and creates a JavaBean property name from it. This is the name of the bean context used for the templates. So if the bean class name is com.acme.Order and then the bean context name, there will be an βorderβ for the purpose of the templates.
Source: http://www.smooks.org/guide