[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: limit a string to a certain word count

Subject: Re: limit a string to a certain word count
From: Kamal Bhatt <kbhatt@xxxxxxxxx>
Date: Wed, 14 Mar 2007 11:19:41 +1100
Re:  limit a string to a certain word count
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.