Version 10

    High-level Smooks Configuration Editor User Guide

     

    Table of Contents

    What is Smooks?

     

    Smooks is a Java Framework/Engine for processing XML and non-XML data (CSV, EDI, Java, etc.).

     

    Smooks can be used to:
    * Perform a wide range of Data Transforms
    * Populate a Java Object Model from a data source
    * Process huge messages and split, transform, and route message fragments to a variety of destinations
    * Enrich messages with data from Databases or other data sources
    * Perform Extract Transform Load (ETL) operations by using Smooks' Transformation, Routing, and Persistence functionality

     

    For more information, check out the Smooks User Guide online.

     

    How do I use the Smooks Configuration Editor?

     

    The easiest way is to create a project (Java project, an ESB project, etc.), right-click and select New -> Other to open the New wizard. Drill into Smooks -> Smooks Configuration File and continue through the wizard. We recommend using a minimum Smooks level of 1.1 or 1.2, but if you're using it in a deployed service, it depends on what version your runtime supports.

     

    Once the file is created, it will open in the Smooks Configuration Editor.

     

    Configuring Your Input

     

    On the Process page of the editor, look for the "Input Task" in the Process Map at the top of the page. Select it and you will see properties to set for the Input reader for your Smooks configuration.

     

    "Input type" corresponds to the type of data that you will be working with. For example, to work with incoming CSV (Comma-separated Values) data, you would specify "CSV" in the drop-down.

    Each reader has slightly different configuration details that must be set in the "Input configuration" area. For instance, the CSV reader requires you to specify details such as the encoding, quote character, separator character, and the list of incoming fields. The EDI reader requires the encoding and the path to the Mapping Model describing the incoming data.

     

    In the "Input data" section, you specify some sample data that conforms to your reader configuration. For example, if you have a sample file of CSV data, you can specify that. Or if you have some sample EDI data, you can specify that.

     

    Once you've specified your reader configuration and sample data, you can see the input model rendered in tree form in the "Input model" section.

     

    What next?

     

    So now that you have your Input data defined, what can you do with it?

     

    Though there are many options in Smooks as far as what you can do with input data as far as transformation, routing, and persistence, the first release of the Smooks Configuration Editor focuses on just a couple of areas: mapping to java and applying templates to create different output formats.

     

    If you have a set of Java classes you want to use the incoming data for, you can use the "Java Mapping" task to specify those classes and use drag and drop to map between the input model generated by the reader and elements in the output model.

     

    Or if you simply want to transform your output to one or more formats, you can use the "Apply Template" task to map it to a CSV file, XML or XSD file (and other formats in the future).

     

    Java Mapping

     

    If you decide to do Java Mapping, you will need to make sure that your Input reader has been set up and you have some sample data specified.

     

    Select the "Input Task" in the Process Map pane and click the plus (+) sign to the right of the icon. Select "Java Mapping" from the popup menu and it will appear to the right, connected to the "Input Task". Then select the "Java Mapping" task.

     

    Right-click on the canvas in an empty space and select "Add ->Java Class". The "Java Bean Creation" wizard appears.

     

    Specify a unique identifier for the new class, the class path, whether it's an array or not, and if it is a collection, also specify the collection class. If the Java class is specified, you'll see a list of the properties in the box below. Click Finish when you're done.

     

    Now with the input and output models on the canvas, you can click and drag from the various input elements to corresponding output elements. Make sure to connect collection elements to corresponding collection elements.

     

    And that's all there is to it.

     

    Apply Template

     

    The "Apply Template" task works very similarly to the "Java Mapping" task, where you map between an input model and an output model.

     

    Select the "Input Task" or "Java Mapping" task you want to use as the input model in the Process Map pane and click the plus (+) sign to the right of the icon. Select "Apply Template" from the popup menu and it will appear to the right, connected to the task you created it from. Then select the "Apply Template" task.

     

    Once you've defined your template model, you can click and drag from the various input elements to corresponding output elements in the template. Make sure to connect collection elements to corresponding collection elements.

     

    Options

     

    At this time, there aren't many additional options available for the Smooks configuration. However, on the Options page of the editor you can see the version you specified when the file was created (as a read-only field) and you can change a couple of defaults:

     

    1. "Stream Filter Type" determines the type of processing model that will be used. Either SAX or DOM. Please refer to Filtering Process Selection in the Smooks user guide for more information about the processing models. In the editor, we set the default to SAX.

     

    2. "Default Serialization is On" is a checkbox that determines if default serialization should be switched on. This is checked by default. Please look for "default.serialization.on" in the Smooks user guide for additional information.

     

    Source

     

    The Source page presents the raw XML for the Smooks Configuration file. As you change properties of the configuration on other pages, the XML for the configuration changes as well.

     

    Testing

     

    For testing see: Using the Smooks Run Configuration to test Smooks Configurations