Generating the XSLT map with the XSLT mapper

This recipe will explore how to configure the Transform activity. We will create an XSLT transformation file and use it to map the output variable of a web service to the response variable of the BPEL process. In this recipe, we will convert the semicolon delimited result text into an XML-formatted result.

Getting ready

If we now run the BPEL process we created in the previous recipe without the Transform activity, we will get a simple string response as shown in the following screenshot:

Getting ready

The response can be read well from the screen; however, if we need to process the response any further, we need to split the response by the delimiter and process the result. A more applicable solution is to use the XML format, which is easy to process.

We will extend the example from the previous recipe by adding additional elements to the response message. We open the XML_Mapping.xsd file and add the following lines to the processResponse element as follows:

<element name = "processResponse">
  <complexType>
    <sequence>
      <!--element name = "result" type="string"/-->
      <element name = "carBrand" type="string"/>
      <element name = "year" type="int"/>
      <element name = "milleage" type="int"/>
      <element name = "price" type="int"/>
      <element name = "ref" type="string"/>
    </sequence>
  </complexType>
</element>

We need to comment out the previous content of the response message in order to receive only the XML-formatted output.

How to do it…

The following steps show you how to configure the Transform activity in order to transform the semicolon text into XML-formatted content:

  1. In JDeveloper, we remove the AssignWSoutput activity since it no longer correctly maps the output of the web service to the output of the BPEL process.
  2. We replace the assign activity with the transform activity and name it TransformWSoutput.
  3. We right-click on the Transform activity and select Edit. We get the following dialog:
    How to do it…

    We get a set of tabs; the one that interests us is labeled Tranformation.

  4. As we will map the output of the web service to the response of the BPEL process, we follow these actions:
    1. Click on the plus sign (+) and select InvokeCarWS_getAvailableCar_OutputVariable and parameters as a source variable.
    2. From the Target Variable, select outputVariable and payload as Target Part.
    3. Name the mapper file as xsl/TransformCarReservationData and click on the OK button.
  5. We get the XML mapper in JDeveloper with the source variable on the left, a space for mapping the functions in the middle, and a target variable on the right as shown in the following screenshot:
    How to do it…

How it works…

The first part of the work is done when we add the Transform activity to the BPEL process. We then configure the Transform activity with the source and target variables and the XSLT file location definition.

Apart from the Transform activity in the BPEL process, we get the new XSLT configuration file in the JDeveloper project.

The transformation operation now presents the assign activity with an annotation and the copy operation. The copy operation takes the input variable and process it through the ora:doXSLTransformForDoc function. As a result of the function, we assign the content to the output variable.

If we examine the TransformCarReservationData.xsl file, we see that the content is basically empty. What we found is the commented section about mapping the input and output variables and an empty section on the mapping rules.

Note

Don't change the commented section part of the XSLT file. This may result in problems when JDeveloper tries to visualize the XSLT file in the XSLT mapper.

See also

  • In the next recipe, we will perform the operations between the source and target variables. Look at the Using the functions in the transformation operations recipe to see how the functions are used in the XSLT transformation file.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset