Whitespace trimming demo

[ICO]NameLast modifiedSizeDescription

[DIR]Parent Directory  -  
[   ]trim.xsl03-Mar-2004 18:34 2.9K 

Description: XPath's normalize-space() strips leading and trailing whitespace, and also collapses runs of whitespace in the remaining text to a single space character. If you want to only strip the leading and/or trailing whitespace, there is no built-in function to do it. However, it is possible to use other XPath 1.0 functions in combination to strip leading whitespace, and it is possible to use a recursive template in XSLT to strip trailing whitespace. This stylesheet demonstrates both operations.

Requirements: Any XSLT 1.0 processor should be able to handle this, but not all processors optimize tail recursion. Therefore, when processing strings with thousands of trailing whitespace characters, one may run into stack limits.

See also: similar functions implemented in FXSL.