[xsl] xslt 1.1 - one liner

Subject: [xsl] xslt 1.1 - one liner
From: "Hasnain Panjwani" <niansah@xxxxxxxxx>
Date: Thu, 5 Jul 2007 11:06:37 +0200
Hi all,

Here is a very old most asked / answered question: XSLT 1.1: Trimming
leading and trailing spaces. I have looked at multiple solutions,
recursive templates because I need to use it in my code. They all seem
very long and verbose, so I want to know is there is any hit on
processing/speed if I simply use this:

<xsl:value-of select="translate(normalize-space(translate($text,'
&#10;','~')),'~',' &#10;')" />

Basically:
First replace all linefeed characters  - because normalize-space would
remove line-feed cahracter  with some character that you know will
not be used in the text  I used "~"  by using the translate
function. Then use normalize-space, replacing all white space, then
translate the "~" back to line-feed.

This is a one liner solution and it works for me  I just want to know
if this would be slower than a recursive template solution.

Advise would be well appreciated.

Thanks,

Hasnain Panjwani


-- H. Panjwani The Netherlands

--
H. Panjwani
The Netherlands

Current Thread