Creating JET transformations to import UML model information from spreadsheets

You can create a JET transformation project and customize it to import spreadsheet information into a UML model.

Before you begin

You must have the Structured Data Importer features installed.

You must convert the spreadsheet to import into a comma-separated value (.csv) file.


  1. Create a JET transformation project: Click File > New > Other > JET Transformation Project; then complete the steps in the wizard.
  2. In the new project, double-click the plugin.xml file.
  3. On the Extensions page, in the All Extensions section, expand org.eclipse.jet.transform, and click transform.
  4. In the Extension Element Details section, complete the following steps:
    1. In the startTemplate field, specify the project-relative path to the JET template that is the entry point for the transformation. Typically, this template is located in the templates folder of the JET transformation project; for example, templates/main.jet. Depending on the complexity of your project, this template might also be the template that contains the code to parse the spreadsheet information.
    2. In the modelLoader field, specify
  5. Add the corresponding plug-in dependencies.
    1. On the Dependencies page, in the Required Plug-ins section, click Add.
    2. In the Plug-in Selection window, in the Select a Plug-in field, specify
    3. From the Matching items list, select the matching plug-in, and click OK.
  6. Optional: Add the JET tag library to import as an extension of the JET transformation.
    1. On the Extensions page, in the All Extensions section, click (transform), and expand (tagLibraries).
    2. Right-click (tagLibraries), and click New > importLibrary.
  7. Optional: On the Extensions page, in the Extension Element Details section, set the properties of the tag library to import.
    1. In the id field, specify the name of the tag library to import. The JET templates in the transformation project use this identifier to determine which tag library to load, as in this example. Specify an identifier that follows Java™ naming conventions, as in this example: my.jet.tag.library.
    2. In the usePrefix field, specify a prefix that uniquely identifies the tags in this library. Specify a prefix that contains only alphanumeric characters.

      By specifying a prefix, in subsequent references to the tag library, you can use the prefix name instead of the name of the tag library. For example, if you specify a prefix of uml, in the JET template you can specify <uml:element name> instead of <my.jet.tag.library:element name>.

    3. In the autoImport field, specify true.

      By specifying true, when the compiled JET template is invoked by the transformation, this entire tag library is loaded. You do not have to use the taglib directive to load the JET library from the JET template.

      If you specify false, in the JET template, the taglib directive must precede the first invocation of a JET tag, as in the following example:
      <%@taglib prefix="uml" id="my.taglib.jet.uml.umlTags" %>
      <uml:package name="{$curRow/cell[2]}" description="{$curRow/cell[3]}" owner="$ownerVar" />
      When the transformation invokes this JET template, and when the JET template interprets the taglib directive that specifies this tag library, the entire contents of the tag library are loaded.
    Tip: Steps 6 and 7 above are optional. To load the JET tag library the transformation invokes, you can use the taglib directive as shown in the previous step.
  8. Click File > Save.
  9. In the JET template that you specify in step 4.a, add code to read the custom CSV format and generate the correct domain element by using the corresponding JET tag. Consider the following excerpt from a .csv file, where the first row corresponds to the column headings in a spreadsheet, and the next rows create a package called testPackage1 and an actor called testActor in testPackage1.
    Package,testPackage1,Test the creation of a Package.,,,,
    Actor,testActor,Test the creation of an Actor.,,,testPackage1,
    The JET template that parses the preceding excerpt and creates the corresponding UML elements might look like the following code fragment:
    <%@taglib prefix="uml" id=""  %>
    <c:setVariable select="/csv/row[1]" var="header"/>
    <c:setVariable select="0" var="i"/>
    <c:iterate select="/csv/row" var="curRow">
    <c:setVariable select="$i + 1" var="i"/>
    <%-- Skip header --%>
    <c:if test="$i!=1">
    <%-- resolve the owner column 
    Note: TargetObject variable refers to the object that is selected as the target model.--%>
    <c:if test="$curRow/cell[6]!=''">
    <uml:find name="{$curRow/cell[6]}" owner="$TargetObject" findRecursive="true" var="ownerVar"/>
    <%-- create package --%>
    <c:if test="$curRow/cell[1]='Package'">
    <c:if test="isVariableDefined('ownerVar')=false">
    <c:setVariable select="$TargetObject" var="ownerVar"/>
    <uml:package name="{$curRow/cell[2]}" description="{$curRow/cell[3]}" owner="$ownerVar" />
    <%-- create actor --%>
    <c:if test="$curRow/cell[1]='Actor'">
    <c:if test="isVariableDefined('ownerVar')=false">
    <c:setVariable select="$TargetObject" var="ownerVar"/>
    <uml:actor name="{$curRow/cell[2]}" description="{$curRow/cell[3]}" owner="$ownerVar" />

    To view a sample JET template, see the related sample at the end of this topic. In the sample project, in the main.jet file, see the first rows of code that import a row from the file, and observe how the code in the template parses the information to create the corresponding model element. The spreadsheet data in the file to import are parameters that correspond to the cell numbers in the JET template.

  10. Save the changes to the JET template or templates that you updated. If you enabled the Project > Build Automatically option, the project builds automatically. Otherwise, you must build the project manually.

What to do next

You can now import the spreadsheet information by using the Import wizard.