xsl-list
[Top] [All Lists]

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

2007-03-14 01:07:53

   Truly tho, I'm a total XSL newbie & am looking for a handout.  :)

I don't think a forum like this is the best way of making your first few
"hello world" steps. Get yourself a book and spend a few hours with it, try
some of the exercises, then come and ask a specific question when you're
stuck.

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


  How might I make an xsl function for this & how would I call it?
Anyone care to help?

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

Thanks --
Matt



On 3/13/07, Michael Kay <mike(_at_)saxonica(_dot_)com> 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).

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



-----Original Message-----
From: Matthew Pease [mailto:mpease(_at_)gmail(_dot_)com]
Sent: 13 March 2007 23:50
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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


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




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



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



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