Pivot using BPEL

Purpose

During the past weeks my collegues at Amis (Anton and Lucas) are pivotting using SQL and PL/SQL, so why not also do some pivotting in BPEL, just for the fun of it. The pivotting problem is not so much part of a known business process but an exercise to see how difficult or how easy it is to program a feature in a new language.

Pivotting an XML document here means tranform nodes to attributes and vice versa, as shown in figure 1. The nodes in XML document “receiveInput” are transformed to attributes in XML document “callbackClient”.

Figure 1: Pivot by BPEL

BPEL process

The BPEL process is visualized in figure 2 and 3. Generally does the following:

read the input XML

iterate over the item nodes (array process)

copy the transformed nodes as attributes to the output XML document using a XSL-T stylesheet

The heart of the pivot functionality is the transformation as shown in figure 4. I choose to use a XML-T stylesheet instead of creating variables for all nodes, because as node names changes or new nodes are added I do’t have to alter BPEL variables used in the Iterate assign activity, alter the XSL-T and change new message types for input- and output messages should be enough.

The transformation is performed inside the bpelx:append task. Bpelx:append is usually used to append the current row being iterated to the output message. But I do not append the original current row, I append the transformed current row to the output message.

I am not sure why the select must be “/*/ns1:amount” resp. “/*/ns1:name”. Because the root node is “ns1:item”, “/ns1:name” resp. “/ns1:amount” should be enough. But the BPEL engine needed the wildcard.

Summary / Wrap up

Pivotting an XML document using BPEL can be done. It takes a lot of time to do it 1st time and it resulted in some oddities, but who’s counting.

meta

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 236 other subscribers

Email Address

About

AMIS is internationally recognized for its deep technological insight in Oracle technology. This knowledge is reflected in the presentations we deliver at international conferences such as Oracle OpenWorld, Hotsos and many user conferences around the world. Our AMIS Technology Blog, the most referred Oracle technology knowledge base outside the oracle.com domain. However you arrived here, we appreciate your interest in AMIS. Link to our Google+ Profile AMIS