This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: count element content length


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]