XSLT Description Character Count

One more related to my previous question. How can I make the following

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

only display a certain number of words (10) instead of the entire description?
KBueschingAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gertone (Geert Bormans)Information ArchitectCommented:
<xsl:value-of select="substring(description, 1, 10)" disable-output-escaping="yes"/>
0
Gertone (Geert Bormans)Information ArchitectCommented:
oops, that is 10 characters, if you really need 10 words, then you will need recursive programming, or make a character estimate (eg. 50 characters instead of 10 words)

do you use XSLT2, or could you?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KBueschingAuthor Commented:
I think what you've given me will do the trick. Not familiar with XSLT2 - I'm using Dreamweaver to set up these pages. If you have an XSLT2 example that does a word count I would certainly be willing to give it a try as well. Thanks again.
0
Gertone (Geert Bormans)Information ArchitectCommented:
The XSLT2 solution would be like this....

Note that string provcessing such as the things you want, make it worthwhile migrating to XSLT2
    <xsl:value-of select="string-join(tokenize(description, '\s+')[position() &lt;= 10], ' ')"></xsl:value-of>

Open in new window

0
Gertone (Geert Bormans)Information ArchitectCommented:
nope, the XSLT inside dreamweaver is XSLT1
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.