Wednesday, April 02, 2008

BI Publisher: How do I replace linefeeds, newline or carriage return whitespace / special characters

Over on the forums, one post came up that is usually a quick answer.

How do I replace newlines (carriage returns or linefeeds) with a space? Well, with BI Publisher Template Builder things weren't exactly going to plan.

Basically you've got an XML element like this:

<sort_field1_inv>110
000
000
110000
0000
0000</sort_field1_inv>

And you want the output to be this: 110 000 000 110000 0000 0000

Should be easy. The 10.1.3.2.0 documentation for xdofx has replace function for replacing strings. Only problem is no mention of special characters. Doh! Okay, just throw in the chr(10) function and should be fine.

So let's try it out:

<?xdofx:replace(SORT_FIELD1_INV,chr(10),' ')?>  

Uh-oh: lovely error message on preview including:

oracle.xdo.parser.v2.XPathException: Extension function error: Method not found 'chr' 

Oh well, lets try some xsl magic similar to the following, including a bunch of variations not presented here!:

<xsl:value-of select='translate(/SORT_FIELD1_INV,"&#x20;&#x9;&#x10;&#x13;&#xD;&#xA;"," ")'/>

Nope, that didn't change anything, still newlines coming through.

Hmm, now what version of the BI Publisher Desktop Word Addin are on? In my case, a tad behind the times, but still matching the documentation that says chr should be available - 10.1.3.2.0 Build 87.

Luckily with Google, a ounce of Japanese reading ability, and of course Babelfish - found that 10.1.3.3.1 or higher would fix this.

So downloaded BI Publisher Desktop 10.1.3.3.2 from this page, uninstalled 10.1.3.2.0, installed 10.1.3.3.2 and now its all go, solution is as previously:

<?xdofx:replace(SORT_FIELD1_INV,chr(10),' ')?>  

Sorted!

UPDATE: Since the eBusiness Suite is still on 5.6.3, the above solution does not work. Here is an alternative solution:

<fo:inline linefeed-treatment="treat-as-space"><?SORT_FIELD1_INV?></fo>

On with it!

5 comments:

Govind said...
This comment has been removed by the author.
Govind said...

Hi,
using worked for me ...thanks a lot...but wat exactly is chr(10) function??...y does it retrun a new line as a new line character??

Thanks,
Govind

3gvideodownlord said...

i really like this News, looks great
1 |2 |3

Sridevi Koduru said...

Regards
Sridevi Koduru (Senior Oracle Apps Trainer Oracleappstechnical.com)
LinkedIn profile - https://in.linkedin.com/in/sridevi-koduru-9b876a8b

Unknown said...

thanks a lot it saved my days