JET now permits the use of '''${''xpath-expression''}''' within the static text as an alternative to the c:get tag. This expression form may also be used in tag attributes values as an alternative to '''{''xpath-expression''}'''.

JET now permits the use of '''${''xpath-expression''}''' within the static text as an alternative to the c:get tag. This expression form may also be used in tag attributes values as an alternative to '''{''xpath-expression''}'''.

+

+

<pre>

+

The value is ${@someModelAttribute}.

+

</pre>

For compatibility, existing JET projects will not support this unless the <transform> element in plugin.xml has the attribute '''enableEmbeddedExpressions="true"'''. New JET projects are created with this attribute set.

For compatibility, existing JET projects will not support this unless the <transform> element in plugin.xml has the attribute '''enableEmbeddedExpressions="true"'''. New JET projects are created with this attribute set.

Line 64:

Line 68:

For example, the template text

For example, the template text

<pre>

<pre>

−

The value of ${'${$foo/@bar}'} is ${$foo/@bar}.

+

The value of ${'${@bar}'} is ${@bar}.

</pre>

</pre>

−

would expand to this text, if $foo/@bar evaluated to ABCDEF:

+

would expand to this text, if @bar evaluated to ABCDEF:

<pre>

<pre>

−

The value of ${$foo/@bar} is ABCDEF.

+

The value of ${@bar} is ABCDEF.

</pre>

</pre>

Line 144:

Line 148:

</pre>

</pre>

−

Child content may be position inside the parent content by using the c:deepContent tag within the c:deepIterate body.

+

Child content may be position inside the parent content by using the c:deepContent tag within the c:deepIterate body. TO produce output such as:

+

+

<pre>

+

node a {

+

node c {

+

node d {

+

} // d

+

node e {

+

} //e

+

} //c

+

} // a

+

node b {

+

node f {

+

node g {

+

} // g

+

node h {

+

} //h

+

} //f

+

node i {

+

} // i

+

} //b

+

</pre>

+

+

You could write this template:

+

+

<pre>

+

<c:deepIterate select="node" initialContext="/root" indent=" ">

+

node ${@name} {

+

<c:deepContent/>

+

} // ${@name}

+

</c:deepIterate>

+

</pre>

+

+

Most attributes on c:deepIterate are optional. If not specified, '''initialContext''' determines the context from surrounding tags. For example, this code is equivalent to the above code.

The c:iterate tag will now set the XPath context object to the object of the current iteration, provided this feature is enabled.

+

+

This permits expressions relative to that object to be shorter. Instead of writing:

+

+

<pre>

+

<c:iterate select="/root" var="root">

+

Description: <c:get select="$root/@description"/>

+

<c:iterate select="$root/node" var="node">

+

Node: <c:get select="$node/@name"/>

+

</c:iterate>

+

</c:iterate>

+

</pre>

+

+

You can now write:

+

<pre>

+

<c:iterate select="/root">

+

Description: <c:get select="@description"/>

+

<c:iterate select="node" var="node">

+

Node: <c:get select="@name"/>

+

</c:iterate>

+

</c:iterate>

+

</pre>

+

+

And, of course, with embedded expressions, you could write:

+

<pre>

+

<c:iterate select="/root">

+

Description: ${@description}

+

<c:iterate select="node" var="node">

+

Node: ${@name}

+

</c:iterate>

+

</c:iterate>

+

</pre>

+

+

Note also that the '''var''' attribute on c:iterate is now optional.

+

+

Also, a new tag '''c:with''' can be used to temporarily set the XPath context object during the evaluation of the block:

+

<pre>

+

<c:with select="/root">

+

Description: ${@description}

+

<c:iterate select="node" var="node">

+

Node: ${@name}

+

</c:iterate>

+

</c:with>

+

</pre>

+

The c:with tag does not iterate. It will evaluate its block only once. If the '''select''' expression does not return a value, the c:with body is not evaluated.

+

+

For compatibility, this behavior is only enabled if the JET variable '''org.eclipse.jet.taglib.control.iterateSetsContext''' is set to '''true()'''. New JET projects have this variable set automatically in the generated main.jet template. Existing JET transformations will need to add a statement such

Easily format generated Java code

XPath function for accessing EMF EClass

A new XPath function, emf.eClass() will access the EClass of an object, if it has one. If object is an XPath variable referring to an EMF Object, then emf.eClass($object)/@name will return its EClass name.

If the argument is not specified, then it defaults to the current XPath context object.

XPath function for accessing UML2 Stereotypes

A new Xpath function, uml2.stereotype will access a stereotype on a UML2 Element, if it has one. If element is an XPath variable referring to
a UML2 element, then uml2.stereotype($element, "Profile-name::Stereotype-name") will access the applied stereotype.

The first argument is optional. If not specified, it defaults to the current XPath context object.

The f:indent tag now preserves user regions

Improved integration with PDE build and international characters

PDE build assumes that all Java files have the same encoding (the default for the JVM executing the build). Prior to this release, JET would set the
encoding a the Java class generated from each template to the same encoding as the template. This could be problematic if the selected encoding was not the one used by PDE build.

The JET compiler now compiles templates into Java classes that always have the default Java encoding. Characters that cannot be represented in that encoding are transformed into Unicode escape sequences.

In addition, a new JET template extension has been defined (.jet2) whose default encoding is UTF-8. The default encoding of files with a .jet use the platform's default encoding for text files - this can change from installation to installation.

Compact alternative to c:get tag

JET now permits the use of ${xpath-expression} within the static text as an alternative to the c:get tag. This expression form may also be used in tag attributes values as an alternative to {xpath-expression}.

The value is ${@someModelAttribute}.

For compatibility, existing JET projects will not support this unless the <transform> element in plugin.xml has the attribute enableEmbeddedExpressions="true". New JET projects are created with this attribute set.

When embedded expressions are enabled, you must escape the ${ if you want them to appear as static text in a template. Escaping is done by including the characters within a string literal inside an embedded expression.

JET can now read .java files

If a JET transformation is given a .java file as input, then JET will create a JDT abstract syntax tree (AST) for the Java file, and allow templates to traverse this AST. The root element of the loaded document is typically compilationUnit.

The child steps available from any ast node are defined by the child and child list property descriptors available on the node.

The attributes available from any ast node are defined by the simple property descriptors available on the node. In addition, the following for attributes are always available:

offset - the 0-based offset of the node within the source

length - the length of the source text corresponding to the ast node

source - the source code corresponding to the ast node

nodeType - the simple class name (no package qualifier) of the AST node

An understanding of the JDT abstract syntax tree APIs is suggested.

As an example, the following XPath expression will return all fields declared in a class

The c:with tag does not iterate. It will evaluate its block only once. If the select expression does not return a value, the c:with body is not evaluated.

For compatibility, this behavior is only enabled if the JET variable org.eclipse.jet.taglib.control.iterateSetsContext is set to true(). New JET projects have this variable set automatically in the generated main.jet template. Existing JET transformations will need to add a statement such
as the following to main.jet to enable this behavior.