< Previous | Next >

Lesson 1.5: Understand JET input models, JET actions, and XPath

This lesson further examines the JET input model, how to use XPath expressions to traverse the input model, and how JET actions relate to the input model.
JET input model

The input models that you create by authoring JET transformations have the following characteristics:

The capabilities of the model are deliberately restrictive to make it easier to create model-to-text transformations quickly without requiring the user to have a deep understanding of metamodel design.

Model processing by JET transformations and invoking actions

The JET Authoring editor generates code to process the input model. This code is located in the main.jet template, and has the following characteristics:

As an example, consider the model in this module. The following image shows the contents of the "Input schema and output actions" pane.
This image shows a type named root that contains an attribute named mailFolder and a type named mailing that contains two attributes and an action named Create file.

The action named Create File: letter.html and the associated JET template (templates/letter.html.jet) are invoked each time a mailing element is encountered under the root element. Both the action and the template have access to two XPath variables: $mailing and $root. Action parameters and text replacements can use any attributes that belong to the element types called mailing and root.

XPath expressions and renaming model elements

The XPath expressions that the JET authoring functionality creates always have the form $variable/@attribute. The JET authoring functionality refactors such expressions if the variable name or the element type is renamed. However, this refactoring does not extend to JET templates. That is, renaming a variable or element type in the JET Authoring editor breaks any XPath expressions in JET templates that use the old variable name.

Lesson checkpoint

This lesson explained the nature of JET input models, and how the input model is linked to JET actions and XPath expressions.
< Previous | Next >

Feedback