xsl-list
[Top] [All Lists]

[xsl] xslt 1.1 - one liner

2007-07-05 02:06:53
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>