Skip to end of metadata
Go to start of metadata

This example illustrates how Smooks can be used to perform Java to Java transforms.

SVN - Download - Other Tutorials

To Build: "mvn clean install"
To Run: "mvn exec:java"


In this particular example, Smooks uses the SAX processing model, which means no intermediate object model is constructed for populating the target Java Object Graph. Instead, we go straight from the source Java Object Graph, to a stream of SAX events, which are used to populate the target Java Object Graph.

Source and Target Object Models

The required mappings from the source to target Object models are as follows:

Source Model Event Stream

Using the Html Reporting tool (see Execution code at end of page), we can see that the SAX Event Stream produced by the source Object Model is as follows:

So we need to target the Smooks Javabean resources at this event stream. This is shown in the Smooks Configuration.

Smooks Configuration

The Smooks configuration for performing this transform ("smooks-config.xml") is as follows (see the Source Model Event Stream above):

Smooks Execution

The source object model is provided to Smooks via a Object. This object is created by passing the constructor the root object of the source model. The resulting JavaSource object is used in the Smooks#filter method. The resulting code could look like as follows:

  • No labels