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

Subject: Re: [xsl] limit a string to a certain word count
From: "Matthew Pease" <mpease@xxxxxxxxx>
Date: Wed, 14 Mar 2007 12:33:29 -0700
Hi Abel & all -

 Thank you very much for your advice & pointers.  Getting the scoop
from some humans is a great way to get started into something.

 The tip for using Saxon 8.9+ will really help.  Also that I probably
want 2.0 do
do these things.

I found these functions online:

  So I am going to go by example & see if I can use the tokenize
function to modify my existing stylesheet call:

<xsl:value-of disable-output-escaping="yes" select="description"/>

into a call that will trim the selected "description"


On 3/14/07, Abel Braaksma <> wrote:
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 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

Current Thread