SemAnt

Wednesday, May 31, 2006

Truncating strings using XSL

Problem
I want to display a RSS feed from Connotea for papers I've tagged with "Formicidae". The titles of these papers can be long, e.g.:
Dracula ant phylogeny as inferred by nuclear 28S rDNA sequences and implications for ant systematics (Hymenoptera: Formicidae: Amblyoponinae)

This takes up too much space when displayed in a panel on the web page, so I want to truncate the titles in a sensible way.

Solution
aaronland.info has a nice solution that truncates to a fixed length, optionally at a word boundary. Our verbose title becomes:
Dracula ant phylogeny as inferred by nuclear 28S...

Much nicer.

(Via Google: xsl truncate string.)



Currently playing in iTunes: Dani California by Red Hot Chili Peppers

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home