Tutorial: Building Your First Data Transformation

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

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.

Figure 3-1 Mapping between source and target types

Mapping between source and target types

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:

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.java

In this task, you create a Transformation file called MyTutorialJoin.java. 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 Package Explorer pane, right-click the src > requestquote folder and from the drop-down menu, select New > Transformation.
  2. The New Transformation dialog box is displayed.
  3. In the Name field, enter MyTutorialJoin.
  4. In the New Transformation dialog box, click Finish.

The MytutorialJoin.java is created under the src > requestquote folder.

Note: To alternatively create Transformation, click the drop down arrow in the Data Palette view, select Integration Controls, and then Transformation.

To Add a Transformation method to MyTutorialJoin

  1. In the Package Explorer pane, double click on MyTutorialJoin.java.
  2. Right-click in the MyTutorialJoin.java Source pane that is displayed.
  3. From the popup menu, select Transform, and then Add XQuery Transformation Method.
  4. Figure 3-2 Transform Pop-up Menu


    Transform Pop-up Menu

  5. In the New XQuery Transformation Method dialog box, type the values for Transformation Method Name, and XQuery File Name fields. For example, Type myJoin as the Transformation Method Name, and myJoin.xq as the XQuery File Name. You can also accept the default values, and click Next.
  6. Select the source (input) types for the transformation from the Source Types dialog box. The available source types are XML, Non-XML, and Java. See To Select the Source Types.
  7. click Next
  8. Select a target (output) type for the transformation from the Target Types dialog box. See, To Select the Target Type.

To Select the Source Types

In this task, you select the source types for the transformation in the Source Types dialog box of New XQuery Transformation wizard. 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, the application XSD files are displayed, as shown in following figure.
  2. Figure 3-3 Available Source Types pane


    Available Source Types pane

    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.
  3. In the Available Source Types pane, expand schemas and PriceQuote.xsd folder, then select the priceQuote element, as shown in the following figure.
  4. Figure 3-4 XML-Types


    XML-Types

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

  7. In the Available Source Types pane, expand AvailQuote.xsd folder, then select the availQuote element.
  8. Figure 3-5 Available Source Types - XML Options


    Available Source Types - XML Options

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

  11. In the Available Source Types pane, select the Java option.
  12. The available Java Types are displayed in the Available Source Types pane.

  13. In the Available Source Types pane, select the float node, as shown in the following figure.
  14. Figure 3-6 Select float node from Available Source Types


    Select float node from Available Source Types

  15. Type taxRate as the Parameter Name.
  16. Click Add
  17. Click Next.

To Select the Target Type

In this task, you select a target type for the transformation in the Target Types dialog box of New XQuery Transformation.

  1. In the Available Target Types pane of the Target Types dialog box, the PriceQuote.xsd, AvailQuote.xsd, Quote.xsd, and QuoteRequest.xsd files are listed.
  2. In the Available Target Types pane, expand Schemas and Quote.xsd folder, then select the quote element, as shown in the following figure.
  3. Figure 3-7 Available Target Types Pane


    Available Target Types Pane

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

  6. Click Finish.
  7. The file: myJoin.xq is created and displayed in the Design view.

    The myJoin Transformation method is added to MyTutorialJoin Transformation file. The myJoin method contains the three source parameters selected from priceQuote.xsd, availQuote.xsd, and the float java type.

    In the Package Explorer pane, representations of the MyTutorialJoin.java and myJoin.xq files are displayed as shown in the following figure.

    Figure 3-8 MyTutorialJoin.Java file in Package Explorer Pane


    MyTutorialJoin.Java file in Package Explorer Pane


  Back to Top       Previous  Next