• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 524
  • Last Modified:

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?
0
KBuesching
Asked:
KBuesching
  • 4
1 Solution
 
Geert BormansInformation ArchitectCommented:
<xsl:value-of select="substring(description, 1, 10)" disable-output-escaping="yes"/>
0
 
Geert BormansInformation 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
 
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
 
Geert BormansInformation 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
 
Geert BormansInformation ArchitectCommented:
nope, the XSLT inside dreamweaver is XSLT1
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now