Sindbad~EG File Manager
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>trim.text</title><link rel="stylesheet" type="text/css" href="../reference.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.2"><link rel="home" href="../index.html" title="DocBook XSL Stylesheets: Reference Documentation"><link rel="up" href="generallibrary.html" title="General Library Templates"><link rel="prev" href="comment-escape-string.recursive.html" title="comment-escape-string.recursive"><link rel="next" href="str.tokenize.keep.delimiters.html" title="str.tokenize.keep.delimiters"><link rel="copyright" href="copyright.html" title="License"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">trim.text</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="comment-escape-string.recursive.html">Prev</a> </td><th width="60%" align="center">General Library Templates</th><td width="20%" align="right"> <a accesskey="n" href="str.tokenize.keep.delimiters.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="trim.text"></a><div class="titlepage"></div><div class="refnamediv"><h2>trim.text</h2><p>trim.text — Trim leading and trailing whitespace from a text node</p></div><div class="refsect1"><a name="d0e33477"></a><h2>Description</h2><p>Given a text node, this function trims leading and trailing
whitespace from it and returns the trimmed contents.</p><a name="trim.text.frag"></a><pre class="programlisting">
<xsl:template name="trim.text">
<xsl:param name="contents" select="."></xsl:param>
<xsl:variable name="contents-left-trimmed">
<xsl:call-template name="trim-left">
<xsl:with-param name="contents" select="$contents"></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="contents-trimmed">
<xsl:call-template name="trim-right">
<xsl:with-param name="contents" select="$contents-left-trimmed"></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$contents-trimmed"></xsl:value-of>
</xsl:template>
<xsl:template name="trim-left">
<xsl:param name="contents"></xsl:param>
<xsl:choose>
<xsl:when test="starts-with($contents,'
') or starts-with($contents,'') or starts-with($contents,' ') or starts-with($contents,' ')">
<xsl:call-template name="trim-left">
<xsl:with-param name="contents" select="substring($contents, 2)"></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$contents"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="trim-right">
<xsl:param name="contents"></xsl:param>
<xsl:variable name="last-char">
<xsl:value-of select="substring($contents, string-length($contents), 1)"></xsl:value-of>
</xsl:variable>
<xsl:choose>
<xsl:when test="($last-char = '
') or ($last-char = '') or ($last-char = ' ') or ($last-char = ' ')">
<xsl:call-template name="trim-right">
<xsl:with-param name="contents" select="substring($contents, 1, string-length($contents) - 1)"></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$contents"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="comment-escape-string.recursive.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="generallibrary.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="str.tokenize.keep.delimiters.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">comment-escape-string.recursive </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> str.tokenize.keep.delimiters</td></tr></table></div></body></html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists