[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: count element content length

Subject: RE: count element content length
From: Jarno.Elovirta@xxxxxxxxx
Date: Tue, 16 Apr 2002 10:49:53 +0300
jarno moilanen
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.