2 <xsl:stylesheet version=
"1.0" xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform">
4 <!-- based on http://plasmasturm.org/log/xslwordwrap/ -->
5 <!-- Copyright 2010 Aristotle Pagaltzis; under the MIT licence -->
6 <!-- http://www.opensource.org/licenses/mit-license.php -->
7 <xsl:template name=
"wrap-string">
8 <xsl:param name=
"str" />
9 <xsl:param name=
"wrap-col" />
10 <xsl:param name=
"break-mark" />
11 <xsl:param name=
"pos" select=
"0" />
13 <xsl:when test=
"contains( $str, ' ' )">
14 <xsl:variable name=
"first-word" select=
"substring-before( $str, ' ' )" />
15 <xsl:variable name=
"pos-now" select=
"$pos + 1 + string-length( $first-word )" />
17 <xsl:when test=
"$pos > 0 and $pos-now >= $wrap-col">
18 <xsl:copy-of select=
"$break-mark" />
19 <xsl:call-template name=
"wrap-string">
20 <xsl:with-param name=
"str" select=
"$str" />
21 <xsl:with-param name=
"wrap-col" select=
"$wrap-col" />
22 <xsl:with-param name=
"break-mark" select=
"$break-mark" />
23 <xsl:with-param name=
"pos" select=
"0" />
27 <xsl:if test=
"$pos > 0">
28 <xsl:text> </xsl:text>
30 <xsl:value-of select=
"$first-word" />
31 <xsl:call-template name=
"wrap-string">
32 <xsl:with-param name=
"str" select=
"substring-after( $str, ' ' )" />
33 <xsl:with-param name=
"wrap-col" select=
"$wrap-col" />
34 <xsl:with-param name=
"break-mark" select=
"$break-mark" />
35 <xsl:with-param name=
"pos" select=
"$pos-now" />
42 <xsl:when test=
"$pos + string-length( $str ) >= $wrap-col">
43 <xsl:copy-of select=
"$break-mark" />
46 <xsl:if test=
"$pos > 0">
47 <xsl:text> </xsl:text>
51 <xsl:value-of select=
"$str" />