# Step 2: Building the Transformation

In this step, you create a transformation that contains the mapping of different source (input) types to a single target (output) type. Specifically, this tutorial provides the steps for transforming a Java primitive and two sets of XML data (valid to two different schemas) to a single set of XML data valid to a third schema, as shown in the following figure.

The RequestQuote business process takes as input a set of widget IDs and returns the price and availability of these widget IDs.

The source parameters to the myJoin Transformation method include the following:

- XML data valid to the PriceQuote.xsd file. The RequestQuote business process of the Tutorial Process application builds a piece of XML data that is valid to the PriceQuote.xsd XML Schema and stores it in a business process variable called priceQuote. This piece of XML data contains a set of widget IDs and their price.
- XML data valid to the AvailQuote.xsd file. The RequestQuote business process of the Tutorial Process application builds a piece of XML data that is valid to the AvailQuote.xsd XML Schema and stores it in a business process variable called availQuote. This piece of XML data contains a set of widget IDs, a boolean that represents if the widget is available, and the ship date.
- A Java primitive of type float called taxRate.

The myJoin Transformation method takes these source parameters and invokes a query which merges the price, availability, and tax rate information into one piece of XML data valid to the XML Schema in the Quote.xsd file.

The tasks in this step include:

- To Create MyTutorialJoin.dtf
- To Add a Transformation method to MyTutorialJoin
- To Select the Source Types
- To Select the Target Type

To Create MyTutorialJoin.dtf

In this task, you create a Transformation file called MyTutorialJoin.dtf. In addition, you create a Transformation method in the Transformation file. During run time, the business process will call this method to invoke the transformation.

1. In the Application tab, right-click the requestquote folder and from the drop-down menu, select New —> Transformation File.
2. The New File dialog box is displayed.
3. In the File name field, enter MyTutorialJoin.dtf.
4. In the New File dialog box, click Create.

In the Design View, a graphical representation of the MyTutorialJoin Transformation file appears, as shown in the following figure.

To Add a Transformation method to MyTutorialJoin

1. In the Design View, right-click in the box representing the MyTutorialJoin Transformation file. (The box shown in the preceding figure.)
2. From the drop-down menu, select Add Transformation method.

A Transformation method is created in the MyTutorialJoin Transformation file.

3. Enter myJoin as the method name.
4. Right-click the arrow representing the myJoin method, as shown in the following figure.

5. From the drop-down menu, select Configure XQuery Transformation Method.

The Configure XQuery Transformation Method - myJoin dialog box is displayed.

The Configure XQuery Transformation Method - myJoin dialog box contains the following two panes:

- Available Source Types—From this pane you select the source (input) types for the transformation.
- Available Target Types—From this pane you select a target (output) type for the transformation.

To Select the Source Types

In this task, you select the source types for the transformation in the Configure XQuery Transformation Method - myJoin dialog box. Source types are the input data types for the transformation—the data types that are transformed to the target data type.

1. In the Available Source Types pane of the Configure XQuery Transformation Method - myJoin dialog box, the application XSD files: PriceQuote.xsd, AvailQuote.xsd, Quote.xsd, and QuoteRequest.xsd are displayed, as shown in following figure.

Note: If these files are not listed, you probably have not loaded the Tutorial: Process Application. For instructions on loading this application, see To Load The Tutorial Process Application.

2. In the Available Source Types pane, expand PriceQuote.xsd folder, then select the priceQuote element, as shown in the following figure.

3. Click Add.

The elements and attributes that make up the priceQuote element are displayed in the Selected Source Types pane.

4. In the Available Source Types pane, expand AvailQuote.xsd folder, then select the availQuote element.

5. Click Add.

The elements and attributes that make up the availQuote element are displayed in the Selected Source Types pane.

6. In the Available Source Types pane, select the Java option.

The available Java Types are displayed in the Available Source Types pane.

7. In the Available Source Types pane, select the float node, as shown in the following figure.
8. In the Name field of the Available Source Types pane, change the name of the Java source variable from floatVar to taxRate as shown in the following figure.

Note: The taxRate mapper variable created in the presiding step is different from the taxRate business process variable of the RequestQuote business process. The variables created in the mapper are used in transformations and not in business processes.

9. Click Add.

To Select the Target Type

In this task, you select a target type for the transformation in the Configure XQuery Transformation Method -myJoin dialog box.

1. In the Available Target Types pane of the Configure XQuery Transformation Method - myJoin dialog box, the PriceQuote.xsd, AvailQuote.xsd, Quote.xsd, and QuoteRequest.xsd files are listed.

2. In the Available Target Types pane, expand Quote.xsd folder, then select the quote element, as shown in the following figure.

3. Click Add.

The elements and attributes that make up the quote element are displayed in the Selected Target Types pane.

4. Click Create Transformation.

The file: myJoin.xq is created and displayed in the Design View.

The myJoin Transformation method is added to the MyTutorialJoin Transformation file. The myJoin method contains the three source parameters selected in the previous steps.

In the Application tab, representations of the MyTutorialJoin.dtf and myJoin.xq files are displayed as shown in the following figure.

Note: In the Application tab, the myJoin.xq appears indented under the MyTutorialJoin.dtf. These files are associated and contain references to each other. To learn more, see The Association Between XQ and DTF Files.

5. Save the MyTutorialJoin.dtf file. Right-click the MyTutorialJoin.dtf file, then in the drop-down menu, select Save.