Tuesday, January 1, 2013

String replace() function in BPEL XSLT

First of all a very Happy New Year to all the readers and the readers to come. May this year brings more prosperity and unending happiness for all across the globe.

This post originates from my recent cerebral exercise of pondering over the best way to replace the occurrence of a string inside another string in XSLT. Especially in BPEL which doesn't have this inbuilt string-replace() function and hence we're bound to have something of our own, this was worth thinking. However, this resulted in additional findings too but with due respect to this post I'd like to keep them with me for the time being. So following lists the ways to have something of our own that can do string replacement. You can choose the best way based on your requirements.

  • Write an XSLT template for string replace function and call this template whenever string replacement is required.
  • Create your own Custom XPath function for String replacement that can be imported in JDeveloper and used across the whole developer team
  • Harness the capabilities of using Java classes in XSLT. This is the simplest method and I'll explain this in just 2 steps, attributed to its simplicity.
    • Create a namespace in XSLT for the Java String class to be used (let's prefix this as  :strClass).
    • Use replaceAll() function of the String class referenced above as highlighted under. And the job is done.
Please note that any function of the String class can be used above and also any of the Java classes can be referenced in the similar way e.g. Math, DOMParser, Integer etc.

Once again Happy New Year and Happy Learning....

5 comments:

  1. Nice post, some really useful tips here! I work for a new social blogging site called glipho.com, and was just wondering if you would be interested in sharing your posts there with us? It wouldn't change your blog in any way, and I know there are many aspiring programmers within our community who would find your work here very interesting. Let me know what you think!

    All the best,

    Teo

    ReplyDelete
  2. Thank you.
    I spent long time to solve missing-replace-function problem.
    Jan

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. hi Neeraj, hi am working on aia o2c pip.could you please let me know about bill info id generated while integrating with brm.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete