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

Subject: Re: [xsl] limit a string to a certain word count
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 14 Mar 2007 12:03:35 +0100
Matthew Pease wrote:

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

XSLT is a very powerful language/tool to have and use, especially so if you choose to use XSLT 2.0. In your OP you said you were using Java. Add Saxon 8.9 to your classpath and get your factory settings correct and you have yourself an XSLT 2.0 processor.



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]

With XSLT 2.0 you can create your own functions, with XSLT 1.0 you cannot. However, 'tokenize()' is already and XSLT 2.0 function and can be used right away.


It seems to me that you need some starting pointers. Like: what is an XSLT Stylesheet, how do you create/initialize one, how do matching templates work etc. Jeni Tennison wrote an excellent introductory book, Michael Kay wrote two excellent reference books and on http://www.w3schools.com you can find a simple tutorial, some examples and a simple reference (but only XSLT 1.0).

But be warned, you may find it a very useful language and, since it is so completely different from imperative languages (like Java, VB, C# etc), you can do many things way easier than you've used to do, but differently ;) You may get addicted so watch out!

-- Abel Braaksma
  http://www.nuntia.nl

Current Thread