Use XSLT to Limit Characters and Words in a String

Usually my response to this kind of request is peppered with hate and discontent – who likes writing recursive templates in XSLT? Anyone?

Good news for people who agree with me – there is actually a really simple solution to this! The following function calls allow you to limit the output of a string (to 49 characters in this example) and calculates where in the string the last space is (so we only break on words). You could update it to find other things – like periods for the end of a sentence, line breaks, special text, etc.

Credit goes to TreeMonkey over at StackOverflow.