# Using a Dynamic Transformation Control

This section describes two ways to use a Dynamic Transformation control. It contains the following topics:

- Using the Base Methods in the Dynamic Transformation Control
- Adding Methods to the Dynamic Transformation Control

### Using the Base Methods in the Dynamic Transformation Control

Once you have created the Dynamic Transformation control, you can add a control instance to your business process and invoke its base methods from within your application.

To learn about adding an instance of the Dynamic Transformation control to your business process, see Create Control Nodes in Your Business Process.

The following methods are available:

- XmlObject[] performXQuery(String xQueryName,HashMap inputList)

Executes an XQuery and the arguments that it operates on based on message context.

- XmlObject performXQueryOnXmlObject(String xQueryName,XmlObject inputDoc,String varName)

Executes an XQuery that takes an XmlObject in and XmlObject out.

- XmlObject performXSLT(String xslTemplate,XmlObject source,HashMap inputList)

Executes an XSLT and the arguments that it operates on based on message context.

- XmlObject convertBytesToXML(byte[] data,String mflUrl)

Executes MFL transformations.

- XmlObject convertInputStreamToXML(InputStream iStream,String mflUrl)

Executes MFL transformations.

- XmlObject convertRawDataToXML(RawData rawData, String mflUrl)

Executes MFL transformations.

- [byte] convertXmlToBytes(XmlObject xmlObject,String mflURL)

Executes MFL transformations from XML data to non-XML data.

- RawData convertXmlToRawData(XmlObject xmlObject,String mflURL)

Executes MFL transformations from XML data to non-XML data.

The @jc:ddtf, @jc:xquery, @jc:xslt annotations control the behavior of these methods. Additional information is also available in the DynamicTransformation Interface.

### Adding Methods to the Dynamic Transformation Control

This section describes how to add methods to the Dynamic Transformation control. It contains the following tasks:

- Adding a New Method to the Dynamic Transformation Control
- Defining the New Method for an XQuery or MFL Transformation

#### Adding a New Method to the Dynamic Transformation Control

In the following steps, you add a new method to the Dynamic Transformation control. After you add the method, you need to define the type of transformation and its parameters.

To Add a New Method to the Dynamic Transformation Control

1. In the Design View, in the Application pane, double-click the JCX file for the Dynamic Transformation control.

A graphical representation of the control is displayed.

2. Right-click the box representing the control, then from the drop-down menu, select Add Method.

A transformation method is created.

3. Right-click the method, then from the drop-down menu, select Rename and rename the method as appropriate.

##### Defining the New Method for an XQuery or MFL Transformation

In the following steps, you select the source and target types from the Source and Target panes of the Dynamic Transformation dialog box. Source types are the input data types for the data transformation—the data types that are transformed to the target data type.

To Define a Method for an XQuery Transformation

Note: To make the schema representations available in the Available Source Types and Available Target Types pane, the XSD and MFL files that contain these schemas must be imported into a Schemas project folder and the current application must have completed building. To learn more, see Creating Schema Projects.

1. Right-click the method you created, then from the drop-down menu, select Add Transformation Method.

The Dynamic Transformation dialog box is displayed.

2. From the Transformation Type drop-down menu, select XQuery.
3. Specify a source type by doing one of the following:

To specify an XML, Non-XML, or Java primitives source type:

1. In the Available Source Types pane, select the desired source type for the XML, NonXML, or Java options.
2. Select a source element.
3. Click Add.

The element and its attributes are added to the Selected Source Types pane.

To specify a Java class source type:

1. The Java class for conversion must be available in the current project. To learn more about including a Java class in your project, see Using Existing Applications.
2. In the Type field of the Available Source Types pane, enter the full package name of the Java class. For example, for a class named Book in the package named org.library, in the Type field, enter: org.library.Book.
3. If desired, change the default name provided in the Name field. This field specifies the name the mapper uses to refer to this element.
4. Click Add.

Note: To learn more, see Using Java Classes in Transformations.

4. Specify a target type by doing one of the following:

Note: Only one target type can be specified.

To specify an XML, Non-XML, or Java primitives target type:

1. In the Available Target Types pane, select the desired source type for the XML, NonXML, or Java options.
2. Select a target element.
3. Click Add.

The element and its attributes are added to the Selected Target Type pane.

To specify a Java class target type:

1. The Java class for conversion must be available in the current project. To learn more about including a Java class in your project, see Using Existing Applications.
2. In the Type field of the Available Target Type pane, enter the full package name of the Java class. For example, for a class named Book in the package named org.library, in the Type field, enter: org.library.Book.
3. If desired, change the default name provided in the Name field. This field specifies the name the mapper uses to refer to this element.
4. Click Add.

The element and its attributes are added to the Selected Target Type pane.

Note: To learn more, see Using Java Classes in Transformations.

The Dynamic Transformation dialog box should look similar to the following figure.

5. If desired, select the Schema Validate Parameter and/or Schema Validate Return check boxes.

If a check box is selected, during run time, the parameters are validated against their schema types before the transformation is executed. To learn more, see Schema Validating During Run Time.

Note: The Schema Validate Parameters and Schema Validate Return check boxes are only enabled if all the parameters and the return type are typed XML or typed MFL types.

6. Click Create Transform.

The transformation is created and the Dynamic Transformation dialog boxes closes. The new method is displayed in the control instance on the Data Palette.

Note: To learn about adding a control instance to your business process with the method you created, see Create Control Nodes in Your Business Process.

This completes the configuration of the method for the transformation. It links the transformation file with the selected method.

The @jc:ddtf and @jc:xquery annotations control the behavior of these methods. All of the attributes of these annotations are optional and have default values. For more information, see Dynamic Transformation Control Annotations.

##### Defining the New Method for an XSLT Transformation

1. Right-click the method you created, then from the drop-down menu, select Add Transformation Method.

The Dynamic Transformation dialog box is displayed.

2. From the Transformation Type drop-down menu, select XSLT.
3. If your XSLT accepts parameters, add the parameters to the transformation method:

1. In the Name field, enter the name of the appropriate parameter.
2. From the Type drop-down menu, select the data type of the parameter.
3. Click Add. The parameter is added to the Parameters field.

Notes: The parameter name entered in the Name field must match the parameter name specified in the XSLT file.
The order of the parameters is not significant. The parameters of the XSLT are matched to the parameters of the transformation method by name.

4. Click Create Transform.The transformation is created and the Dynamic Transformation dialog boxes closes. The new method is displayed in the control instance on the Data Palette.

Note: To learn about adding a control instance to your business process with the method you created, see Create Control Nodes in Your Business Process.

This completes the configuration of the method for the XSLT transformation. It links the XSLT file with the selected method in the transformation file. During run time, if the business process invokes this method, this XSLT is invoked.

The @jc:xslt tag controls the behavior of the Dynamic Transformation control. All of the attributes of the @jc:xslt tag are optional and have default values.

For more information on the @jc:xslt tag, see Dynamic Transformation Control Annotations.

Related Topics

Dynamic Transformation Control Annotations

Creating Schema Projects

Using Existing Applications

Using Java Classes in Transformations

Create Control Nodes in Your Business Process

Dynamic Transformation Interface