# Selecting Source and Target Types

In the following tasks, you select the source and target types from the Source or Target panes of the Configure XQuery Transformation Method - methodName dialog box. (Where methodName represents the current Transformation method.) Source types are the input data types for the data transformation—the data types that are transformed to the target data type.

This section contains the following tasks:

- To Select the Source and Target Types
- To Change the Selected Source or Target Parameters
- Updating the Graphical Representation Displayed in the Source View of a XQ File

To Select the Source and Target Types

1. Select or create a Transformation file.

For instructions on creating a Transformation file see To Create a Transformation File From the Menu Bar.

To select an existing Transformation file:

1. In the Application tab, expand the folders that contain the Transformation file. (If the Application tab is not visible in WebLogic Workshop, choose View —> Application from the menu bar.)
2. In the Application tab, double-click the Transformation file (ends in the .dtf extension).

2. Select or create a method from a Transformation file.

For instructions on creating a method in a Transformation file, see To Add a Transformation Method to Transformation File.

To select an existing method, in the Design View of the Transformation file (ends in the .dtf extension), right-click the arrow representing the method, as shown in the following figure:

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

The Configure XQuery Transformation Method dialog box is displayed. In the Available Source Types pane of Configure XQuery Transformation Method dialog box, the list of available source types are displayed.

Note: In order for schema representations to be available in the Available Source Types and Available Target Types pane, the XSD and MFL files which contain these schemas must be imported into a Schemas project folder and the current application must have completed building. To learn more, see Selecting Source and Target Types.

4. Select the desired source type from the XML, Non-XML, and Java options.
5. Specify an 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, expand the schema and element folders, until you find the desired element.
2. Select an source element.
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.

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, enter: org.library.Book in the Type field.
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.

To learn more, see Using Java Classes in Transformations.

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

Note: Non-XML Types/Untyped/RawData is not supported as a source or target type for a Transformation method. RawData has no associated structure and therefore can not be transformed using the mapper. To learn more, see Create a New Instance of an MflObject From Untyped Raw Data Example.

6. Repeat step 5 for an additional source types.

Note: Multiple source types can be specified.

7. Specify an target type, by doing one of the following:

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

1. In the Available Target Types pane, expand the schema and element folders, until you find the desired element.
2. Select an target element.
3. Click Add.

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 Types pane, enter the full package name of the Java class. For example, for a class named Book in the package named org.library, enter: org.library.Book in the Type field.
3. Click Add.

To learn more, see Using Java Classes in Transformations.

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

Note: Only one target type can be specified.

8. If desired, select the Schema Validate Parameters check box.

If this check box is selected, during run time the source 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 check box will only be enabled if all the parameters and the return type are typed XML or typed MFL types.

9. If desired, select the Schema Validate Return check box.

If selected, during run time the target parameter is validated against its schema type after the transformation is executed. To learn more, see Schema Validating During Run Time.

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

10. Click Create Transformation.

Note: You do not have to select an source type but you must select an target type.

An XQ file (ending in the .xq extension) is created to store the query and displayed in the Application tab. The query is written in the XQuery language. XQ files are associated with a particular DTF file and appear indented under the associated DTF file in the Application tab. To learn more, see The Association Between XQ and DTF Files.

To Change the Selected Source or Target Parameters

If links have been created between source and target types in the Design View of an XQ file, then XQuery code has been generated which refers to the source and target types.

If you change the source and target types of the query, the existing XQuery code remains unchanged and may be referencing the original source or target types which may be no longer valid for this query. The XQuery code in the query may now be invalid and may require some manual XQuery code clean up as described in the last step in the following task.

Note: You may be able to minimize the amount of clean-up required by using the same name for the source variable in both the original and new query. Instead of having different names for the original and new source variables, for example: oldOrderDoc/po-number and newOrderDoc/po-number, respectively, use the same name: orderDoc/po-number for both.

To change or add source parameters or change the target parameter:

1. Select the Transformation file (ends in the .dtf extension) that contains that Transformation method:

1. In the Application tab, expand the folders that contain the Transformation file. (If the Application tab is not visible in WebLogic Workshop, choose View —> Application from the menu bar.)
2. In the Application tab, double-click the Transformation file (ends in the .dtf extension) that contains the Transformation method.

2. Select the method from the Transformation file. In the Design View of the Transformation file, right-click the arrow representing the method.
3. From the drop-down menu, select Reconfigure XQuery Transformation Method.

The Configure XQuery Transformation Method dialog box is displayed.

4. Remove and add elements in the Available Source Types and Available Target Types pane as desired.
5. If desired, select the Schema Validate Parameters check box.

If this check box is selected, during run time the source 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 check box will only be enabled if all the parameters and the return type are typed XML or typed MFL types.

6. If desired, select the Schema Validate Return check box.

If selected, during run time the target parameter is validated against its schema type after the transformation is executed. To learn more, see Schema Validating During Run Time.

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

7. Click Edit Transformation.
8. Clean up the XQuery code if required. If you changed the source and target types of the query, the existing XQuery code remains unchanged—the XQuery code is not regenerated and therefore any references in the XQuery code to the original source or target types remain in the query. These references may be invalid for this query depending on what source and target types were changed as described in the following guidelines:
9. If you added an additional source type, no XQuery code clean up is required.
10. If you remove an existing source type, the XQuery code that references the removed source type will be invalid and may need to be removed.
11. If you change the existing source or target types, the XQuery code that references the changed source or target type may be invalid depending on differences between the old and new schemas and may need to be removed.

To view the XQuery source code including any errors:

1. In the Application tab, expand the folders that contain the XQ file. (If the Application tab is not visible in WebLogic Workshop, choose View —> Application from the menu bar.)
2. In the Application tab, double-click the XQ file that contains XQuery code.
3. Select the Source View tab.

The XQuery code is displayed and the invalid XQuery code is underlined in red.

12. Fix the errors reported in the Source View. To view a detailed description of an error, move the mouse over the error in the Source View.

If desired, you can delete all the XQuery code in the Source View of the XQ file by removing all the XQuery source code after the namespace declaration(s) and recreating your links in the Design View.

Updating the Graphical Representation Displayed in the Source View of a XQ File

The following procedure describes how to force the mapper to display an updated graphical representation of an XQ file in the Design View, if you have manually changed the source or target parameters of a Transformation method in the Source View of the Transformation file. To update the graphical representation of the XQ file, complete the following steps:

1. View the Transformation file that contains the query (stored in the XQ file) in the Design View:

1. In the Application tab, expand the folders that contain the Transformation file. (If the Application tab is not visible in WebLogic Workshop, choose View —> Application from the menu bar.)
2. In the Application tab, double-click the Transformation file (ends in the .xsd extension).
3. Select the Design View tab.

2. Select the desired Transformation method from a Transformation file:

1. Right-click the arrow representing the method.
2. From the drop-down menu, select Reconfigure XQuery Transformation Method.

The Configure XQuery Transformation Method dialog box is displayed.

3. Click Edit Transformation.

The graphical representation of the object is displayed in the Design View of the XQ file.