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

RE: split string to whole words based on length

Subject: RE: split string to whole words based on length
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 26 Apr 2006 16:57:02 +0100
xslt split into words
I think this kind of problem requires recursion even in 2.0: at least, if
you want it to be remotely efficient.

Michael Kay

> -----Original Message-----
> From: andrew welch [mailto:andrew.j.welch@xxxxxxxxx] 
> Sent: 26 April 2006 16:06
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  split string to whole words based on length
> I'm sure there's a good xslt 2.0 way of doing this that 
> doesn't involve a recursive named template or function.  In 
> fact I'm sure it's come up a few times but I can't find it in 
> the archives.
> Given a string of comma delimeted words and a length, split 
> the string into substrings so that whole words are kept 
> intact with proper use of the delimiter, where no string 
> exceeds the length.
> So, given the following:
> <xsl:variable name="str" select="'one,two,three,four,five'" 
> as="xs:string"/> <xsl:variable name="length" select="10" 
> as="xs:integer"/>
> Should be output as:
> <words>one,two</words>
> <words>three,four</words>
> <words>five</words>
> As I say, I'm sure there's a quality solution to this, rather 
> than the long winded recursive approach.
> Any takers?

Current Thread


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.
First Name
Last Name
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.