Sunday, January 22, 2012

Inserting a New Line character in message using BPEL XSLT

In a requirement, we were trying to format the data fetched from DB (in XML format in BPEL) into a String variable with a new line inserted after each record. So that the data below would appear in the String variable like Following is the simple transformation to achieve the same.

<xsl:for-each select="/ns0:SelectFromLookupOutputCollection/ns0:SelectFromLookupOutput">
<xsl:value-of select='concat(ns0:property_name, ",", ns0:property_value,"&#10;")'/>
</xsl:for-each>

Key Points to Note:

  • The magic lies in the word &#10; which serves as a new line character in XSLT (11g). In above case, it gets appended at the end of each record resulting in new line at the end of each record.
  • The function somehow doesn't work in SOA Suite 11.1.1.3 (BUG-13602524, thanks to my colleague Nivea for identifying this) but works in 11.1.1.4 and older versions.


2 comments:

  1. Hi,
    I'm creating a transformation, follows exemple:

    "Test = " variable
    line break
    "Test = " variable
    line break

    but when I set this value
    to line break, it value is delete when I open the editor, why??

    ReplyDelete
  2. Concat(... worked great for me. Thanks for the tip!

    ReplyDelete