If you only want the words, then (assuming XSLT 2.0) something of the form tokenize(following-sibling::text(),'\W')[position() lt 6] or tokenize(preceding-sibling::text(),'\W')[position() gt last()-5] should do the trick. However, this loses the separators between the words. If it's necessary to retain the separators as well as the words, then a more complex solution using xsl:analyze-string is called for.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|