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:


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

Should be easy. The 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 - Build 87.

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

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

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


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!


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

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??


3gvideodownlord said...

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

Sridevi Koduru said...

Sridevi Koduru (Senior Oracle Apps Trainer
LinkedIn profile -

Unknown said...

thanks a lot it saved my days