This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: count element content length
- From: Jarno dot Elovirta at nokia dot com
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 16 Apr 2002 10:49:53 +0300
- Subject: RE: [xsl] count element content length
- Reply-to: xsl-list at lists dot mulberrytech dot com
Heppa,
> You are right, but I am not at that level yet =)
> But hey! If I do like Santtu suggested, the result is a bit
> wrong since
> it adds "..." also to elements that are shorter than 20
> characters. What to do?
<xsl:template match="Subject">
<p>
<xsl:value-of select="concat(substring(., 1, 20), substring('...', 1 div (string-length(.) > 20), 3))" />
</p>
</xsl:template>
It uses the Becker method for adding the '...' the string length is greater than 20. See the archives or e.g. Jeni's book for further explanation.
Cheers,
Santtu
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list