The function normalize-space
replaces sequences of whitespaces by a single space and trims the provided string. How can I only trim the string without the repla
Using FXSL (open source library for XSLT functional programming, written entirely in XSLT) one simply writes:
'
'
When this transformation is applied on the provided XML document:
To get more information look at: www.example.com
the wanted, correct result is produced:
'To get more information look at: www.example.com'
How does the trim template work?
It trims the left leading whitespace, then it reverses the resulting string and trims its leading whitespace, then it finally reverses the resulting string.
II. XPath 2.0 solution:
Use:
replace(replace(/*/description, '^\s*(.+?)\s*$', '$1'), '^ .*$', '')
Here is an XSLT - 2.0 - based verification:
" "
When this transformation is applied on the provided XML document (above), the XPath expression is evaluated and the result of this evaluation is copied to the output:
"To get more information look at: www.example.com"