Abel Braaksma wrote:
Please note the subtle differences between the above mentioned
solution and the one I proposed. Both have their pros and cons.
Depending on your final needs, one or the other may suit you best.
Using [as the above mentioned solution suggested]
<xsl:analyze-string select="." regex="^(\s*)(.+?)(\s*)$">
will match the total string, so no need for using
non-matching-substring. This has the advantage that you can do
string-manipulation on the whole match at once, using regex-group(1),
(2) and (3). If you only do string-replacement, your can optimize this
with the replace() function.
Though familiar with RegExp functions in various languages, I am not
sure how this one works, so I wonder what happens when the condition of
the first regex group cannot be satisfied. Supposing that the second
matches, will I then have to refer to it as regex-group(1) or still as
regex-group(2)? I.e., do the numbers index the groups defined in the
regex or the substrings that actually matched one of the groups?
Doing
<xsl:analyze-string select="." regex="^\s+|\s+$">
is quicker, has the advantage of separating logic, but has the
disadvantage that you cannot intermix the matching and non-matching
strings (meaning, when you are in non-matching-substring, it contains
the non-space content of your match, and you cannot get the
matching-substring from that instruction and vice versa).
The latter technique seems to perfectly solve my task of simply
"squeezing" leading and trailing spaces from element content out into
mixed content.
Thank you again for your efforts in providing me all this information.
Yves
--~------------------------------------------------------------------
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>
--~--