# How Do I: Add or Edit an XQuery Map with the XQuery Mapper Dialog?

You can use the XQuery Mapper dialog to override natural mapping for XML messages sent between your service and clients, other services, or other resources. The dialog provides tabs to display the parameter-xml map and return-xml map. You display the dialog in Design View by double-clicking the method to which the map will apply.

XQuery maps are designed to map one schema to another. When you create an XQuery map, you have the XML schema (XSD) file defining the message you will be mapping. The other schema is derived from your Java signature by WebLogic Workshop. When mapping, you define XQuery expressions that express how parts of one message fit into the shape of the other message.

Keep in mind when mapping that a web service operation expects the incoming message to be of a particular shape — for example, a shape that shows the method name as the only child of the soap body element. For example, the following operation method:

    public String[] getTitles(String[] title)
    {
        ...
    }

will have an inbound shape like this:

    <getTitles>
        <title>
            <String>book 1 title</String>
            <String>book 2 title</String>
        </title>
    <getTitles>

To Begin a Custom XQuery Map

1. Create a schema project and add to it the XSD containing the schema to which you will be mapping.

   For more information on schema projects and compiling schema, see How Do I: Use XML Schema in WebLogic Workshop?

2. Double-click the map icon corresponding to the method, callback, or callback handler to which you are applying the map.

   The XQuery Mapper dialog appears, as shown here:

3. Click one of the following tabs, as appropriate:

   - Click the Parameter XML tab to map XML values to the parameters of your Java declaration

   - Click the Return XML tab to map XML values to the return value of your Java declaration.

4. Click Choose to browse for the schema that represents the message to which you are mapping.
5. In the Select Schema Element dialog, expand the name of the XSD file you compiled, select the schema element to which you will be mapping, then click OK.

   The XQuery Mapper dialog displays a sample of the XML message defined by the schema you selected.

6. Click Edit XQuery.
7. The XQuery Mapper - Edit XQuery dialog will be displayed.

   On the left, under Source Schema, you will see a representation of parts of the XML as defined in your schema. On the right, under Target Schema, you will see the schema derived by WebLogic Workshop from your Java signature.

8. Edit the XQuery map so that you describe how parts of the source schema map to parts of the target schema.

   For simple maps, the edit process is purely graphical. To create a simple map, you click a schema part under source schema, then drag over to the target schema, dropping it on the schema part to which you want to map it. This is illustrated here:

   For more complex maps, you will want to edit the XQuery expression directly.
9. If you want to edit the XQuery expression, click the chevron at the lower right corner of the dialog, to the right of Expand Advanced Options Panel.

   The lower pane will expand to display a function builder which you can use to edit the XQuery function for each part of your map. Note that you can type in the Edit Function pane. You can drag function names from the categorized function list on the left, then drop them in the center pane. You can also drag parameter names from the right into the center pane.

   To view the complete XQuery as you edit, click the XQuery tab at the top of the dialog. To test your map, click the Test tab, then click the Test button.

10. Click OK when you have finished you map.

For examples of both simple and complex maps, see the XQuery map samples provided with WebLogic Workshop, in the SamplesApp application.

Related Topics

Introduction to XQuery Maps