Creating derived attributes for JET transformations

You can create derived attributes in a transformation input schema to represent attributes whose values are calculated or constructed from one or more existing values in the transformation input schema.

Before you begin

You must have a transformation model file open. A transformation model file has the name transform.tma.

About this task

By invoking XPath functions in an XPath expression, you can create calculations of greater complexity for a derived attribute. You can use derived attributes in XPath expressions in the same way that you use regular attributes.

You can create derived attributes in the editor area, in the Transformation input schema and output actions pane. You can also create them as part of the process of replacing text with a model reference.

To create a derived attribute for a JET transformation:

Procedure

  1. In the editor area, in the Transformation input schema and output actions pane, right-click the input schema element to contain the derived attribute; then click New > Derived Attribute.
  2. In the Create New Derived Attribute dialog box, in the Attribute name field, specify a name for the attribute.
  3. Specify the exemplar text to replace with the derived attribute. Other occurrences of this text are marked with a JET Replace marker, which indicates that the text will be replaced with the derived attribute the next time that you run the Update Project command.
  4. Specify how to derive the value of the attribute. This is typically a string with one or more embedded XPath expressions, enclosed in braces, that represent model references. You can type a calculation, or you can click Insert Model Reference to select an element in the model.
  5. Click OK.
  6. Click File > Save.
    Note: You might need to create a derived attribute when you replace JET action parameter values with input model references. To create a derived attribute when the Replace with Model References dialog box is open, click New. The Create New Derived Attribute dialog box opens, and the Exemplar text and Calculation fields are populated with the action parameter value that you selected. Complete steps 2, 3 (optional), 4 (optional), and 5. Click OK; then click File > Save.

Example

For example, you can create a derived attribute that generates a password for a user account. The generated password is the first letter of the user's given name, plus the user's family name, and the entire password is lowercase. Assume that the JET transformation has an attribute called givenName that represents the given name of a user, and an attribute called familyName that represents the family name of a user. These attributes are contained in an element called mailing, which represents an e-mail message that the JET transformation generates. The following XPath expression calculates the password: {lower-case(concat(substring($mailing/@givenName,1,1), $mailing/@familyName))}.

What to do next

A JET Replace marker is added to the JET templates at each occurrence of the exemplar text that you specify. You must run the Update Project command to generate the code for the new derived attribute in the main.jet template.

Feedback