Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

JET FAQ What kind of input model can JET handle?

Revision as of 12:11, 10 August 2009 by Pelder.ca.ibm.com (Talk | contribs) (Model loaders)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Question

What kind of input model can JET handle?

Answer

This is a two part answer. JET is capable of loading models, and of navigating them using XPath expressions. These are different capabilities.

Model loaders

Out of the box, JET can load the following kinds of Eclipse workspace resources:

  • XML documents (they get loaded usings EMF's generic XML mechanisms, not the W3 DOM), so, they are EMF models in memory.
  • EMF-base models. That is any model that was created via EMF, and for which there is a registered Resource Factory
  • The Eclipse Workspace itself.

By default, JET will attempt to load a workspace resource as an EMF file. However, each type of loading is represented by a 'model loader' which can be explicitly declared in the JET transformation's plugin.xml on the Extension tab. The following table shows the out-of-the-box model loaders defined in JET. These model loader IDs may also be specified in the c:load and c:loadContent tags.

Model loader ids defined by JET
ID Description
org.eclipse.jet.emfxml Load XML document via EMF's generic XML support
org.eclipse.jet.emf Load EMF document looking up the files extension in the EMF Resource Factory registry
org.eclipse.jet.resource Load an Eclipse IResource as an IResource

To tell JET to use a specific model loader when running a transformation, set the modelLoader attribute on the JET transformation extension in plugin.xml. This sample explicitly sets the model loader to org.eclipse.jet.emf

<plugin>
   <extension
         id=""
         name=""
         point="org.eclipse.jet.transform">
      <transform
            enableEmbeddedExpressions="true"
            modelLoader="org.eclipse.jet.emf"
            startTemplate="templates/main.jet"
            templateLoaderClass="foo.bar10.compiled._jet_transformation">
 
 ... rest of file omitted
 
      </transform>
   </extension>
</plugin>

XPath navigation

Out of the box, JET can navigate the following input models using XPath expressions:

  • XML documents (represented in the w3 document object model - W3 DOM)
  • EMF-based models
  • The Eclipse workspace resources (IResource, IContainer, IFolder, IProject, IFile).

Navigating XML documents with XPath is well defined. JET provides some enhancements for navigating EMF models. Below are some examples of navigating the Eclipse workspace with XPath:

<c:load url="{$org.eclipse.jet.resource.project.name}" 
        urlContext="workspace" 
        var="myProject" 
        loader="org.eclipse.jet.resource"/>
<c:log>
  Contents of <c:get select="$myProject/@name"/>:
  <c:iterate select="$myProject/*" var="child">
    <c:get select="$child/@name"/> (<c:get select="local-name($child)"/>)
  </c:iterate>

  Attributes of <c:get select="$myProject/@name"/>:
  <c:iterate select="$myProject/@*" var="attr">
    <c:get select="local-name($attr)"/> = <c:get select="$attr"/>
  </c:iterate>
</c:log>


Back to the M2T-JET-FAQ

Copyright © Eclipse Foundation, Inc. All Rights Reserved.