Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'doc/org.eclipse.jet.doc/tasks/usingJetWithEMF.xhtml')
-rw-r--r--doc/org.eclipse.jet.doc/tasks/usingJetWithEMF.xhtml229
1 files changed, 0 insertions, 229 deletions
diff --git a/doc/org.eclipse.jet.doc/tasks/usingJetWithEMF.xhtml b/doc/org.eclipse.jet.doc/tasks/usingJetWithEMF.xhtml
deleted file mode 100644
index c9e83aa..0000000
--- a/doc/org.eclipse.jet.doc/tasks/usingJetWithEMF.xhtml
+++ /dev/null
@@ -1,229 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
-
- <head>
-
- <title>Using JET Transformations with EMF Documents</title>
-
- <link charset="ISO-8859-1" href="../book.css" rel="STYLESHEET"
- type="text/css"/>
-
- </head>
-
- <body>
-
- <h2>Using JET Transformations with EMF Documents</h2>
-
- <p>By default, JET transformations expect an XML document as
- input. However, JET transformations can be modified to load EMF-based
- models, too. This section describes how to load EMF documents
- with JET and how JET accesses the models.</p>
-
- <h3>Loading EMF Documents</h3>
-
- <p>To enable a JET Transformation to load an EMF document, the transformation&#39;s plugin.xml
- must be modified.
- Do the following:</p>
-
- <ol>
-
- <li>Open the plugin.xml file in the root of the JET
- transformation project.</li>
-
- <li>Click on the <strong>Extensions</strong> tab.</li>
-
- <li>Expand the <strong>org.eclipse.jet.transform</strong> element in
- the <strong>All Extensions</strong> tree. This will reveal the
- <strong>(transform)</strong> child element.</li>
-
- <li>Click on the <strong>(transform)</strong> element.</li>
- <li>In the <strong>modelLoader</strong>
- field, enter <code>org.eclipse.jet.emf</code> .</li>
-
- </ol>
-
- <h3>XPath expressions against EMF documents</h3>
-
- <p>The JET XPath processor handles EMF documents by mapping the document&#39;s
- meta-model to the XPath infoset model as follows:</p>
-
- <ul>
-
- <li>
- <a href="PLUGINS_ROOT/org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore/resource/Resource.html"
- >Resource</a> objects map to the infoset <i>;root</i> object.
- The XPath expression <code>/</code> refers to the Resource
- containing the input model.</li>
-
- <li>The Resource contents, as returned by the
- <a href="PLUGINS_ROOT/org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore/resource/Resource.html#getContents()"
- >getContents()</a> method, maps to an element
- <i>contents</i>. The XPath expression <code>/contents</code>
- returns the results of this method.</li>
-
- <li>Each
- <a href="PLUGINS_ROOT/org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore/EReference.html"
- >EReference</a> feature on an object is mapped to an element with
- the same name.
- If <code>$class</code> refers to an EObject with an EReference <code>ownedAttributes</code>, then
- <code>$class/ownedAttributes</code> will return all the elements in that collection.
- </li>
-
- <li>Each
- <a href="PLUGINS_ROOT/org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore/EAttribute.html"
- >EAttribute</a> feature on an object is mapped to an attribute
- with the same name.
- If <code>$class</code> refers to an EObject with an EAttribute <code>name</code>, then
- <code>$class/@name</code> will return the value of this attribute.
- </li>
-
- <li>When evaluating XPath child-axis expressions, JET will first
- attempt to identify an feature with the requested name. If no
- feature is found, then the contained children of the element are
- searched for instances of an EClass with the specified name.
- For example, if the <code>$class</code> refers to an EObject that contains instances of an EClass <code>Property</code>
- in any of its reference features, the <code>$class/Property</code> will return those objects.
- </li>
-
- </ul>
-
- <h3>Example: XPath expressions against .ecore files</h3>
-
- <p>If a JET transform loads an ECore model (a .ecore file), then the following
- XPath expressions would return the following results:</p>
-
- <table border="1">
-
- <thead align="left">
-
- <tr>
-
- <th>XPath expression</th>
-
- <th>Java equivalent</th>
-
- </tr>
-
- </thead>
-
- <tbody>
-
- <tr>
-
- <td><code>/contents</code></td>
-
- <td><code>Resource.getContents()</code></td>
-
- </tr>
-
- <tr>
-
- <td><code>/EPackage</code></td>
-
- <td>the subset of <code>Resource.getContents()</code> of type
- <code>EPackage</code></td>
-
- </tr>
-
- <tr>
-
- <td><code>$ePackage/eClassifiers</code> (ePackage is an
- EPackage instance)</td>
-
- <td><code>ePackage.getEClassifiers()</code></td>
-
- </tr>
-
- <tr>
-
- <td><code>$ePackage/EClass</code></td>
-
- <td>the subset of <code>ePackage.eContents()</code> of type
- <code>EClass</code></td>
-
- </tr>
-
- <tr>
-
- <td><code>$ePackage/@name</code></td>
-
- <td><code>ePackage.getName()</code></td>
-
- </tr>
-
- </tbody>
-
- </table>
-
- <h3>Accessing XPath Variables from Java code</h3>
-
- <p>JET templates may contain Java code, and this Java code may
- access XPath variables. This is particularly valuable when the
- input model is EMF-based. The following examples handles
- hypothetical ECORE model loaded by a JET transform, and accesses
- the model with both XPath and Java expressions</p>
-
- <pre>&lt;%-- contents of main.jet that reads handles a .ecore file --%&gt;
-&lt;%-- import the ecore namespace, needed for Java expressions --%&gt;
-&lt;%@jet imports=&quot;org.eclipse.emf.ecore.*&quot;%&gt;
-
-&lt;c:setVariable var=&quot;ePackage&quot; select=&quot;/contents&quot;/&gt;
-
-&lt;%-- write to the JET execution console --%&gt;
-&lt;c:log&gt;
-EPackage: &lt;c:get select=&quot;$ePackage/@name&quot;/&gt;
-&lt;c:iterate select=&quot;$ePackage/eClassifiers&quot; var=&quot;eClassifier&quot;&gt;
-&lt;%
-EClassifier ec = (EClassifier)context.getVariable(&quot;eClassifier&quot;);
-%&gt;
- EClassifier: &lt;c:get select=&quot;$eClassifier/@name&quot;/&gt;. Really it&#39;s &lt;%= ec.getName() %&gt;
-&lt;/c:iterate&gt;
-&lt;/c:log&gt;</pre>
-
- <h3>Details of EMF Document loading</h3>
-
- <p>JET uses the EMF method ResourceSetImpl.createResource()
- to create a Resource implementation capable of loading themode.
- This requires the model&#39;s EPackage is registered with EMF in order to load model
- instances.</p>
-
- <p>The Model loader id for EMF document loading is
- <code>org.eclipse.jet.emf</code>.</p>
-
- <h3>Loading EMF documents during transformation execution</h3>
-
- <p>The launch framework automatically handles the loading of EMF resources passed to a JET
- Transformation as input. If required, JET templates can load other EMF-based documents
- during execution.
- The
- <a href="PLUGINS_ROOT/org.eclipse.jet.doc/references/taglibs/controlTags/loadTag.html"
- >&lt;c:load&gt;</a> and
- <a href="PLUGINS_ROOT/org.eclipse.jet.doc/references/taglibs/controlTags/loadContentTag.html"
- >&lt;c:loadContent&gt;</a> tags may be used for this purpose.
- The former loads a document from
- an file, while the second loads the document by parsing the content of the c:loadContent tag.</p>
-
- <p>The following loads the mymodel.ecore file that is part of the transformation plug-in:</p>
-
- <p><code>&lt;c:load url=&quot;mymodel.ecore&quot;
- loader=&quot;org.eclipse.jet.emf&quot;
- var=&quot;myEcore&quot;/&gt;</code></p>
-
- <p>The following example loads the file mymodel.ecore from a workspace
- project myproject.</p>
-
- <p><code>&lt;c:load url=&quot;myproject/mymodel.ecore&quot;
- urlContext=&quot;workspace&quot;
- loader=&quot;org.eclipse.jet.emf&quot;
- var=&quot;myEcore&quot;/&gt;</code></p>
-
- <p>Finally, while it is possible to load ecore models with
- <a href="PLUGINS_ROOT/org.eclipse.jet.doc/references/taglibs/controlTags/loadContentTag.html">
- &lt;c:loadContent&gt;</a>, the format of Ecore models often makes
- this impractical to embed a document within a JET template.</p>
-
- </body>
-
-</html>
-

Back to the top