Skip Headers
Oracle® SOA Suite Developer's Guide
10g (10.1.3.1.0)

Part Number B28764-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

7.5 Creating a Transformation

A transformation maps the elements of a source schema to the elements of a target schema. Because a web service typically specifies the format required for incoming data, for example, the format of an invoice, you need a transformation to map the source data schema, for example, a purchase order, to the target data schema.

You use the transform activity to add transformation logic to a BPEL process. The transformation defines the source and target variables, the message parts to map, and the XSL map file. To specify the source and target schema mapping, you use the XSLT Mapper, shown in Figure 7-12.

Figure 7-12 The XSLT Mapper

Description of Figure 7-12 follows
Description of "Figure 7-12 The XSLT Mapper "

The source and target schemas that you identify when creating the XSL map are displayed in the XSLT Mapper. To copy an attribute or leaf-element in the source to an attribute or leaf-element in the target, drag and drop the source to the target. To do more complex mappings, drag and drop functions into the mapper canvas (in the center) and connect the functions to the source and target nodes. From the Component Palette, the following mapping functionality is available:

BPEL processes and ESB projects can use the same XSLT.

The Property Inspector, shown in Figure 7-13, displays the properties of a selected XSD element.

Figure 7-13 Property Inspector

Description of Figure 7-13 follows
Description of "Figure 7-13 Property Inspector"

See Oracle BPEL Process Manager Developer's Guide for information on the following transformation and XSLT Mapper topics:

7.5.1 How to Create a Transformation

To create a transformation, use a transform activity and the XSLT Mapper, which assigns elements of a source schema to the elements of a target schema.

To create a transformation:

  1. Drag and drop a Transform activity into the BPEL process.

  2. Double-click the Transform activity.

  3. Use the Transform dialog (shown in Figure 7-14) to enter source and target schema information.

    Figure 7-14 Creating a Transformation

    Description of Figure 7-14 follows
    Description of "Figure 7-14 Creating a Transformation"

    1. Select the source variable from which to map elements.

    2. Select the source part of the variable (for example, a payload schema consisting of a purchase order request) from which to map.

    3. Select the target variable where elements are mapped to.

    4. Select the target part of the variable (for example, a payload schema consisting of an invoice) to which to map.

    5. Enter a mapper file name or accept the default name (or use the flashlight icon to browse for a file).

      This file stores the mapping you create using the XSLT Mapper transformation tool.

    6. Click the Create Mapping icon.

    7. Use the XSLT Mapper to drag and drop from source attributes or leaf-elements to target attributes or leaf-elements, as shown in Figure 7-12. Use the functions in the Component Palette and the automap feature to simplify this task.

You can also create an XSL map file from an XSL stylesheet. From the File main menu in Oracle JDeveloper, click New, then XML, and then XSL Map From XSL Stylesheet.

See Oracle BPEL Process Manager Order Booking Tutorial for step-by-step instructions on dragging from source to target in the XSLT Mapper.

7.5.2 What Happens When You Create a Transformation

When you use the XSLT mapper, the transformation is captured in an XSL map file. Example 7-5 shows the source code for TransformOrder.xsl, which maps the order schema in SOAOrderBooking.wsdl to the database schema required by the Order web service.

Example 7-5 Source Code for TransformOrder.xsl

<?xml version="1.0" encoding="UTF-8" ?>
<?oracle-xsl-mapper
  <!-- SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY. -->
  <mapSources>
    <source type="WSDL">
      <schema location="SOAOrderBooking.wsdl"/>
      <rootElement name="SOAOrderBookingProcessRequest" namespace="http://
        www.globalcompany.com/ns/OrderBooking"/>
    </source>
  </mapSources>
  <mapTargets>
    <target type="XSD">
      <schema location="Order_table.xsd"/>
      <rootElement name="OrdersCollection" namespace="http://
        xmlns.oracle.com/pcbpel/adapter/db/top/Order"/>
    </target>
  </mapTargets>
  <!-- GENERATED BY ORACLE XSL MAPPER 10.1.3.1.0(build 060515.0101) AT [SAT JUL 08 16:58:22 PDT 2006]. -->
?>
<xsl:stylesheet version="1.0"
                xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
                xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
                xmlns:ns1="http://xmlns.oracle.com/SOAOrderBooking"
                xmlns:ns4="http://www.globalcompany.com/ns/OrderBooking/rules"
                xmlns:ns0="http://www.w3.org/2001/XMLSchema"
                xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
                xmlns:xp20="http://www.oracle.com/XSL/Transform/java/
                  oracle.tip.pc.services.functions.Xpath20"
                xmlns:client="http://www.globalcompany.com/ns/OrderBooking"
                xmlns:ns2="http://xmlns.oracle.com/pcbpel/adapter/db/top/Order"
                xmlns:cu="http://www.globalcompany.com/ns/customer"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:po="http://www.globalcompany.com/ns/order"
                xmlns:wf="http://schemas.oracle.com/xpath/extension"
                xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
                xmlns:orcl="http://www.oracle.com/XSL/Transform/java/
                  oracle.tip.pc.services.functions.ExtFunc"
                exclude-result-prefixes="xsl plnk ns4 ns0 client po ns2 bpws hwf xp20 wf ids orcl">
  <xsl:template match="/">
    <ns3:OrdersCollection>
      <ns3:Orders>
        <ns3:comments>
          <xsl:value-of select="/client:SOAOrderBookingProcessRequest/po:PurchaseOrder/
            po:OrderInfo/po:OrderComments"/>
        </ns3:comments>
        <ns3:itemsCollection>
          <xsl:for-each select="/client:SOAOrderBookingProcessRequest/po:PurchaseOrder/
            po:OrderItems/po:Item">
            <ns3:Items>
              <ns3:partnum>
                <xsl:value-of select="po:partnum"/>
              </ns3:partnum>
              <ns3:price>
                <xsl:value-of select="po:price"/>
              </ns3:price>
              <ns3:productname>
                <xsl:value-of select="po:ProductName"/>
              </ns3:productname>
              <ns3:quantity>
                <xsl:value-of select="po:Quantity"/>
              </ns3:quantity>
            </ns3:Items>
          </xsl:for-each>
        </ns3:itemsCollection>
      </ns3:Orders>
    </ns3:OrdersCollection>
  </xsl:template>
</xsl:stylesheet>