[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: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 14 Mar 2007 00:08:28 -0000
RE:  limit a string to a certain word count
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).

Michael Kay
http://www.saxonica.com/

 

> -----Original Message-----
> From: Matthew Pease [mailto:mpease@xxxxxxxxx] 
> Sent: 13 March 2007 23:50
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  limit a string to a certain word count
> 
> Hello all -
> 
>   I'm a wee Java programmer who has been assigned a task 
> that, as it turns out, requires XSL to complete.
> 
>   I don't know a thing about XSL.
> 
>   What I need is a function that will limit a string to a 
> certain number of words.
> 
>   I guess what I'm asking for is a small miracle.  Any takers?
> 
> Thank you-
> Matt

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.