xsl-list
[Top] [All Lists]

Re: [xsl] limit a string to a certain word count

2007-03-13 17:14:16
Michael Kay wrote:
You mean, truncate it to a certain number of words?

In XSLT 2.0, that's

tokenize($in, '\W')[position() = 1 to $n]

where $in is your input string and $n is the number of words.

It's a fair bit harder in XSLT 1.0 (most things are).
Depends if your 1.0 parser supports str:tokenize (a EXSLT function). If it does, then it not a "fair bit harder" but it will be "a wee bit harder" :)

See here:

http://www.exslt.org/str/functions/tokenize/index.html

I think Xalan supports this function if you are using it.



--
Kamal Bhatt


--~------------------------------------------------------------------
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>
--~--