Here's what I did to solve this problem the other day.
Code:
<xsl:template match="/">
<xsl:for-each select="$currentPage/node>
<xsl:if test="string(data [@alias = 'articleBlurb']) != ''">
<xsl:value-of select="data [@alias = 'articleBlurb']" disable-output-escaping="yes"/>
</xsl:if>
<xsl:if test="string(data [@alias = 'articleBlurb']) = ''">
<xsl:call-template name="FirstWords">
<xsl:with-param name="words" select="25"/>
<xsl:with-param name="text" select="umbraco.library:StripHtml(data [@alias='articleBody'])"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:template>
<!-- ================================================================================== -->
<xsl:template name="FirstWords">
<xsl:param name="words"/>
<xsl:param name="text"/>
<xsl:if test="$words >= 1">
<xsl:if test="umbraco.library:LastIndexOf($text, ' ') > 0">
<xsl:value-of select="substring-before($text, ' ')" disable-output-escaping="yes"/><xsl:text> </xsl:text>
</xsl:if>
<xsl:if test="umbraco.library:LastIndexOf($text, ' ') <= 0">
<xsl:value-of select="$text" disable-output-escaping="yes"/>
</xsl:if>
<xsl:call-template name="FirstWords">
<xsl:with-param name="words" select="$words - 1"/>
<xsl:with-param name="text" select="substring-after($text, ' ')"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
The reason for the FirstWords template is so that it can be called recursively for each word in the text.
This works well for short word counts but trying to grab the first 2000 words would be slow. If you need many words, another approach should be taken by either rewriting the xslt or creating an inline C# function or creating an xslt extension.
cheers,
doug.
MVP 2007-2009 - Official Umbraco Trainer for North America -
Percipient Studios