Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you are asking is an XSLT <a href="http://en.wikipedia.org/wiki/Ellipsis" rel="nofollow noreferrer"><strong>ellipsis</strong></a> generator.</p> <p>May be this <a href="http://www.dpawson.co.uk/xsl/sect4/N10301.html#d16170e189" rel="nofollow noreferrer">xslt 1.0 template</a> might give you some idea:</p> <p>Here is the main gist of it:</p> <pre><code>&lt;xsl:template match="text()" mode="label"&gt; &lt;xsl:param name="self-x"/&gt; &lt;xsl:param name="self-y"/&gt; &lt;xsl:variable name="text" select="normalize-space(.)"/&gt; &lt;!-- a quick and dirty way to avoid problems with line breaks --&gt; &lt;!-- replace the select attribute with this call if you want to use a fancier way to escape whitespace characters: &lt;xsl:call-template name="escape-ws" &lt;xsl:with-param name="text" select="." / &lt;/xsl:call-template --&gt; &lt;use xlink:href="#text-box" transform="translate({$self-x} {$self-y})"/&gt; &lt;!-- text nodes are marked with a little box --&gt; &lt;text x="{$self-x + $writing-bump-over}" y="{$self-y - $writing-bump-up}" style="{$text-font-style}; stroke:none; fill:{$text-color}"&gt; &lt;xsl:text&gt;"&lt;/xsl:text&gt; &lt;xsl:value-of select="substring($text,1,$max-text-length)"/&gt; &lt;!-- truncate the text node to $max-text-length --&gt; &lt;xsl:if test="string-length($text) &amp;gt; $max-text-length"&gt; &lt;!-- add an ellipsis if necessary --&gt; &lt;xsl:text&gt;...&lt;/xsl:text&gt; &lt;/xsl:if&gt; &lt;xsl:text&gt;"&lt;/xsl:text&gt; &lt;/text&gt; &lt;/xsl:template&gt; </code></pre> <p>Note: </p> <ul> <li>you will need to replace the ellipsis by a link, but the main idea is there.</li> <li>this represents only a small extract of the <a href="http://www.dpawson.co.uk/xsl/sect4/N10301.html#d16170e189" rel="nofollow noreferrer">all script</a></li> <li>you may not need everything in it: if you need "<code>&lt;use xlink:href="...</code>", you need to <a href="http://osdir.com/ml/web.svg/2004-01/msg00032.html" rel="nofollow noreferrer">declare the xlink namespace</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload