Sunday, February 22, 2009

Load XSL at runtime on the fly

While working for a project objective, we had lots of stylesheet (XSLT) files in the BPEL processes, which underwent frequent modifications. The XSL files were created and stored under a common folder inside the BPEL process, which required deployment of the BPEL process everytime we made changes to the stylesheets.

This seemed very bad and time consuming, as we were compiling and deploying the entire BPEL process even for the smallest change in the stylesheet. Then I found a solution where the BPEL process would be made to pick up / load the stylesheet during runtime which will be stored at some physical location under the $SOA_Home accessible via a http URL.

By dynamically constructing the http URL in the BPEL process, the BPEL process was able to load the stylesheets dynamically thereby eliminating the tight coupling between the stylesheet configuration & BPEL process.

# Create a folder called "xsl" (user-defined) under the following location;
$SOA_Home\bpel\system\xmllib

# Place all your XSLT files under the xsl folder

# Construct the dynamic HTTP URL as shown below for this folder location in your BPEL process

1. Create a copy operation under the Assign activity which will construct and store the http URL for the xsl folder, and assign the value to a variable; say xsl_variable
concat(substring-before(ora:getProcessURL(),ora:getDomainId()),'xmllib/xsl/',bpws:getVariableData('stylesheet1'))
2. Pass this variable (In this example xsl_variable) as the first parameter to the ora:processXSLT() function

After the above said modifications are performed, the stylesheets can be modified and copied into the xsl folder which will be loaded & transformed by the BPEL processes on the fly.

12 comments:

  1. Great! Really works well. One question. Did you already thought about generate XSLT files automatically, seeking the transformation rules on a database?

    ReplyDelete
  2. Hi Rodrigo,

    That is the next best thing on my 'to explore' list. I will take sometime to do the R&D on this approach and will post the method!!!

    ReplyDelete
  3. Hi Sathya,

    I'm thinking of doing something similar for the XSDs the File Adapter, is it possible?

    ReplyDelete
  4. Hi Satya, Thanks for this post. For this can we use MDS as well?

    ReplyDelete
    Replies
    1. Absolutely, and that's the recommended approach. This post was written during the SOA 10g days ;)

      Delete
    2. Thanks for your post, Is there any approach to do the same in SOA 12c?

      Delete
    3. Hi Goutham,

      Absolutely.
      The best approach would be to leverage MDS to store your stylesheets and then use functions like doXSLTransform or doXSLTransformForDoc to load your xslt dynamically.

      Delete
  5. Replies
    1. Hi,

      Yes. you can most certainly achieve this in 11g/12c. Leverage your MDS repository (DB MDS is recommended for production deployments) to store your stylesheets and use BPEL XPath functions such as doXSLTransform*** to load and process your stylesheets dynamically.

      Delete
  6. Satya,Thanks for the comment .. can we do it as its suggested in the blog... by keeping the xsls in the folder and then generate http url to load the style sheet.

    ReplyDelete
    Replies
    1. As you can see this blog is dated - written during the SOA 10g days. Now you can do this in much more sophisticated way. Once you have your resources (in this case xsl) on MDS you can access them using the oramds:/ protocol... No need to generate a HTTP url. Refer to my post here to learn more about MDS:
      http://sathyam-soa.blogspot.com/2012/11/soa-11g-mds-share-common-artifacts.html

      Delete