JBoss.orgCommunity Documentation

Smooks Developer Tools Reference Guide

Version: 1.1.1.GA


1. Introduction
1.1. Key Features of Smooks Tools
1.2. What is Smooks?
1.3. What is Smooks Tools?
1.4. Adding Smooks jars
2. Tasks
2.1. New Smooks Configuration File Creation
2.2. Input Task Configuring
2.3. "Java Mapping" or "Apply Template"?
2.4. Java Mapping Task
2.5. Apply Template Task
2.6. Smooks Configuration testing using Smooks Run Configuration
3. Reference
3.1. Process tab
3.1.1. Processing Task section
3.1.2. Selected Task Details Section
3.2. Options Tab
3.2.1. Smooks Configuration section
3.2.2. Filter Settings Filter section
3.3. Source Tab
3.3.1. XML Source Editor
3.3.2. Error underlining in Graphical Editor
3.3.3. Smooks Configuration File Validator
3.4. Properties View
3.4.1. Decode Configuration
3.4.2. Apply Template Wizard
4. Summary
4.1. Other relevant resources on the topic

This chapter gives you a short introduction to Smooks, Smooks tools and its installation.

First, have a look at the key features of Smooks tools:

This chapter describes the main tasks that can be performed with Smooks tools. In this chapter we use the example that can be downloaded from here.

This chapter includes detailed reference information on all tabs in the Smooks Configuration Editor.

The Process tab of the Smooks Configuration Editor provides a way to configure different types of transformations. By default the smooks configuration file is opened in this editor. If you have set another editor to open the file by default, you should right click on the smooks configuration file and select Open WithSmooks Configuration Editor.

The Process tab has two sections:

You can see them on the picture below.


The options available in this section depends on the selected task in the Processing Task section. Because there are 3 types of tasks there are 3 different sets of its options in the Selected Task Details Section. They will be described one by one.

On the picture below you can find an example of the Selected Task Details Section view if XML is selected as input type.


As you can see on the picture above the Input Configuration section is empty for XML input file. However, this section has special configuration options for CSV,EDI,JSON,Custom input files.

Here are the screens of these configuration options:

All the input task configuration positions can be found in the table below:

Table 3.2. Selected Task Details Section. Options for Input Task.

OptionDescriptionDefault
Input typeSelect your type of input file. If you don't find your type in the list, you should use Custom type:
  • No Input

  • XML

  • Java

  • XSD/WSDL

  • CSV

  • EDI

  • JSON

  • Custom

XML
Input configuration
  • No Input - no info required

  • XML - no info required

  • Java - no info required

  • XSD/WSDL - no info required

  • CSV

    • Fields - Comma separated list of CSV record field names

    • Separator Character - Field separator character.

    • Quote Character - Quote character.

    • Record Name - Name of csv record element.

    • Root Name - Name of csv root element.

    • indent - Add indentation character data to the generated event stream. This simply makes the generated event stream easier to read in its serialized form. Useful for testing etc.

    • Skip Lines - Number of lines to skip before processing starts.

  • EDI

    • Target Profile - Defines the output transformation profile

    • Encoding - The character encoding.

    • Mapping Model - Defines the EDI Mapping Model configuration for processing the EDI message stream to a stream of SAX events that can be processed by Smooks.

    • Validate - This attribute turns on/off datatype validation in the EDI Parser. Validation is on by default. It makes sense to turn datatype validation off on the EDI Reader if the EDI data is being bound into a Java Object model.

  • JSON

    • Target Profile - Defines the output transformation profile

    • Array Element Name - The element name of an array element.

    • Encoding - encoding: The default encoding of any JSON message InputStream processed by this Reader.

    • Illegal Element Name Char Replacement - If illegal characters are encountered in a JSON element name then they are replaced with this value. By default this is not defined, so that the reader doesn't doesn't search for illegal characters.

    • Indent - Add indentation character data to the generated event stream. This simply makes the generated event stream easier to read in its serialized form. Useful for testing etc.

    • Key Prefix on Numeric - The prefix character to add if the JSON node name starts with a number. By default this is not defined, so that the reader doesn't search for element names that start with a number.

    • Key Whitespace Replacement - The replacement character for whitespaces in a JSON map key. By default this not defined, so that the reader doesn't search for whitespaces.

    • Null Value Replacement - The replacement string for JSON NULL values.

    • Root Name - The element name of the document root.

    • Key Maps - Defines a JSON element name mapping The "from" key will be replaced with the "to" key or the contents of the element.

  • Custom

    • Target Profile - Defines the output transformation profile

    • Class - Custom reader class.

    • Handlers - Set a handler on the reader instance e.g. an EntityResolver, ErrorHandler etc.

    • Features - Reader Features List

    • Parametres - Resource Parameters

  • CSV

    • not defined

    • ','

    • '"'

    • csv-record

    • csv-set

    • true

    • 0

  • EDI

    • not defined

    • UTF-8

    • not defined

    • true

  • JSON

    • not defined

    • element

    • UTF-8

    • not defined

    • false

    • not defined

    • not defined

    • ""(an empty string)

    • 'json'

    • not defined

  • Custom

    • no defaults

Input DataYou should select a data file using the Add and Delete buttons 
Input Model ViewUsing this view you can see the structure of your input file.If the file has been changed, to see the changes click the Refreshlink. 

Selected Task Details section for this task is presented by the graph, which eases the process of java mapping.


This graphical editor allows you to perform drag&drop operations with the nodes of transformed data to map the source data to target data. When you save the changes in the graphical editor the correct Smooks configuration file content will be generated.

Using the popup menu in the Selected Task Details section you can manage the diagram elements on the canvas.

The descriptions of the popup menu options are in the following table.


This section describes Options tab of the Smooks Configuration File editor, and gives short recommendations how this tab can be used during the project configuring.


Properties View is available for some elements on the canvas of Java Mapping and Apply Template Tasks, like:

To add Properties View to the opened perspective the user can either open WindowShow ViewPreferences in the toolbar or right click the element which properties he wants to inspect and select Properties in the popup menu. On the picture below you can see how this view looks like when some csv template is selected.


This view is fully synchronized with the canvas of the Smooks Configuration Editor. This means that when you change the selected element by clicking on it, the properties of a new element are immediately displayed in it. Using Properties View you can then edit all the properties of the selected item.


Smooks tools support decode parameter configuration through the Decode tab in Properties View activated by clicking the connection between input model and bean items.

On the picture below you can see an example of decode configurations for mapping an Input Model Item to a Date format:


The descriptions of the Decode Configuration tab options are listed in the following table:


The Decoder Parameters section for EnumDecoder quite differs from other types of decoders. See the picture below:


The Decoder Parameters section for EnumDecoder in Properties View consists of 2 rows:

  • From Data Value - The lines in this row are editable. You can change them according to the names of enum types you used in input file.

  • To Enum Value - The lines in this row are not editable. Here a set of all constants declared in mapped Enum type is listed. The user is responsible for correspondence between the values in these two rows.

For more information about different decoder parameters read the Smooks Technology Documentation.

The Apply Template Wizard helps you to add a new Apply Template Task to the Smooks configuration file. You can call it from the popup menu when the Java Mapping item in the Processing Task section is selected by following Add TaskApply Template (see Figure 2.9, “Apply Template configuration” picture).

The wizard consists of several pages:

  1. The first one includes only one option to adjust.The user should select in which of the two formats(XML or CSV) he prefers to create an output message:


  2. The second page is specific for each of the output message formats:

The document summarizes the capabilities of Smooks Tools, and provides some instructions on how to use them. The chapters above also walked you through the steps on creating and configuring a XML to JAVA mapping project. If you have questions or suggestions concerned both the documentation and tools behavior, you are welcome to JBoss Tools Users forum. Please, use Jira to report bugs and requests on documentation.

All JBoss Developer Studio/JBoss Tools release documentation can be found at http://docs.jboss.org/tools in the corresponding release directory.

The latest documentation builds are available at http://download.jboss.org/jbosstools/nightly-docs.

For more information about Smooks technology please visit the Smooks Technology Home Page

You can find a collection of screencasts covering the Smooks tools technology here.