Create new JBoss Tools Documentation Jira issue

This will launch the Jboss Tools Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.orgCommunity Documentation

Smooks Dev Tools Reference Guide

Version: 1.1.0.GA


1. Introduction
1.1. Key Features of Smooks Tools
1.2. What is Smooks?
1.3. What is Smooks Tools?
1.4. How to install Smooks dev tools?
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. Smooks Configuration Editor
3.1.1. Process tab
3.1.2. Options Tab
3.1.3. Source Tab
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:

The Smooks tools was included by the JBoss Tools since 3.0.0 Beta1 version. You can download the JBoss Tools from JBoss download site.

Smooks tools (JBoss Tools) run with the latest Eclipse and other required plug-ins (GEF, EMF, etc.).

You should download the latest IDE for Java EE developers from Eclipse site. It contains many plug-ins ( GEF, EMF, etc. ) required by Smooks dev tools.

The Smooks Configuration depends on having all of the appropriate Smooks runtime jars in the path of the Eclipse Plug-in or Java Project in the Eclipse workspace. The easiest solution is to do the following:

  • 1) Download the Smooks distribution from here: http://www.smooks.org/mediawiki/index.php?title=Downloads . Grab the latest "ALL" distribution (as of today, it is the Smooks v.1.2.2 "ALL" distribution) and it will include binaries, examples, etc.

  • 2) Extract files from the archive somewhere on your machine.

  • 3) In your Eclipse workspace, copy the Smooks jars into a directory of your Eclipse plug-in or Java project named "lib".

  • 4) For your Eclipse Plug-in or Java Project, right-click on the project and select Properties.

  • 5) Select the "Java Build Path" item in the Properties list, select the Libraries tab, and click "Add JARs"

  • 6) In the Jar Selection dialog, select all the jars in the "lib" directory mentioned in step 3 and click OK.

  • 7) Click OK to close the Properties dialog. Now you should see a "Referenced Libraries" node that appeared in your project hierarchy in Eclipse.

Now let's progress to more advanced topics.

This chapter describes the main tasks a user can be faced during Smooks tools usage.

This chapter includes detailed reference information about Smooks Tools.

This chapter describes the following tabs of the Smooks Configuration Editor:

The Process tab of the Smooks Configuration Editor helps to configure different types of transformations. By default smooks configuration file is opened in this editor.If you have another default settings for editor opening you should left click smooks configuration file and select:Open With->Smooks Configuration Editor.

The Process tab has two sections:

You can see them on the picture below.


The options of 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 Selected Task Details Section view if XML is selected as input type.


As you can see on the picture above Input Configuration section is empty for XML input file. But 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 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. Default of ','.

    • Quote Character -Quote character. Default of '"'.

    • Record Name -Name of csv record element.Default:csv-record

    • Root Name -Name of csv root element.Default:csv-set

    • 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.Default:true

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

  • EDI

    • Target Profile -Defines the target profile

    • Encoding -The character encoding. Default "UTF-8"

    • 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 target profile

    • Array Element Name -The element name of a array element. Default of 'element'.

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

    • 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.Default:false.

    • 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. Default is ""(an empty string).

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

    • 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 -

    • 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 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 Refreshlink. 

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


In conclusion, with this document you know all the capabilities of Smooks Tools and could easily start with them. The chapters above walked you through the steps on how to create and configure some 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.